Skip navigation
jamedo1234
Currently Being Moderated

Garbage Collection Question

Sep 11, 2012 2:02 PM

Curious to know if the following would become an issue...

 

public static function setToPoint(view:DisplayObject, point:Point):void

{

   view.x = point.x;

   view.y = point.y;

}

 

// from another class

var testView:Sprite = new Sprite();

StaticUtil.setToPoint(testView, new Point(calculatedX(), calculatedY()));

 

I am basically looking to have a utility class that can handle a bunch of layout tasks. But am worried about passing in DisplayObject parameters, due to the fact that this may cause memory issues. Will implementation like this cause memory issues? Garbage collection issues?

 

Thanks much.

 
Replies
  • Currently Being Moderated
    Sep 11, 2012 3:36 PM   in reply to jamedo1234

    I understood is that it is only a reference, you're not sending the entire object to the method, there should be no problems with memory, or the garbage collection

     
    |
    Mark as:
  • kglad
    63,043 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 11, 2012 10:17 PM   in reply to jamedo1234

    actually, a persistent reference to view (if there was one) in StaticUtil would prevent its gc if it was otherwise readied for gc.  but, judging by what you showed, you don't have a reference to view after setToPoint completes execution.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points