[flexcoders] Memory leaks

3 views
Skip to first unread message

Isabelle Loyer Perso isa_loyer@yahoo.fr [flexcoders]

unread,
Sep 24, 2015, 4:22:37 AM9/24/15
to flexc...@yahoogroups.com
 

Hi
I created an air application with a schedule.

To populate this schedule with appointment, I launch an httpservice and
result is use to populate an array collection. Each time user change
week, a new request is sending.

The variable myDataCalendar (array collection) is defined as [Bindable]
private var myDataCalendar :ArrayCollection;
I try to reuse the same ArrayCollection, but I think making a mistake
because memory increase each time, and garbage collector seems not working!

myDataCalendar = new ArrayCollection();
myDataCalendar.refresh();

So can you help me to understand memory leak.

Best regards

__._,_.___

Posted by: Isabelle Loyer Perso <isa_...@yahoo.fr>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)

.

__,_._,___

shravansofts@yahoo.com [flexcoders]

unread,
Sep 24, 2015, 9:38:57 PM9/24/15
to flexc...@yahoogroups.com
 

Combine variable declaration and object creation in single statement. See the below pseudo code for example:

private var myDataCalendar :ArrayCollection=new ArrayCollection();

function ChangeWeekHandler(Event){
 myDataCalendar= HttpServiceToGetNextWeekData();
 myDataCalendar.refresh();
}
Note: HttpServiceToGetNextWeekData() should return anonymous objectof type ArrayCollection.

Hope this helps. :-)

__._,_.___

Posted by: shrava...@yahoo.com
.

__,_._,___

sherwoodsports@gmail.com [flexcoders]

unread,
Sep 25, 2015, 7:12:15 PM9/25/15
to flexc...@yahoogroups.com
 

To be even more memory conscious, don't instantiate "myDataCalendar" until you have to use it.  Your suggestion indicates you're doing it whenever the object/class instantiates.

function ChangeWeekHandler(Event){
      if(!myDataCalendar) myDataCalendar = new ArrayCollection();
      .
      .
      .
}

On top of that, make sure you free it up (in the case garbage collection doesn't pick it up).  You can do this by simply setting it to null when you're done with it.

myDataCalendar = null;

__._,_.___
.

__,_._,___
Reply all
Reply to author
Forward
0 new messages