PDA

View Full Version : Ext Garbage Collector



Animal
5 Jun 2007, 12:43 AM
The Garbage Collector finds orphaned Elements, that is Ext.Elements who's "dom" HtmlElements have been removed from a document.

I'm thinking it should also find Ext.Components who's elements have been removed from the document.

In my case, I'm creating an Ext.form.BasicForm when loading a fragment into a ContentPanel.

When that ContentPanel is reloaded, a new Ext.form.BasicForm is created. The old one stays registered.

I think I'm building up quite a few orphaned components in my pages.

jack.slocum
5 Jun 2007, 1:09 AM
Yes, that was part of the plan - step by step though. ;) There are a few issues to iron out with Component garbage collection but at this point it looks promising.

Animal
5 Jun 2007, 2:14 AM
Yep, It's the kind of thing I knew you'd have a plan for. Just checking! :)

FuryVII
5 Jun 2007, 6:28 AM
I assume this is part of Ext 2.0 (along with the whole new component model)?

brian.moeskau
5 Jun 2007, 8:46 AM
Actually it's in 1.1 in Element.js. It's currently just a private static function (Element.garbageCollect) that automatically runs on a 30 second interval.

FuryVII
5 Jun 2007, 11:32 AM
Cool, thanks.

cluettr
24 Jul 2007, 5:45 PM
Is there anyway to force the garbage collection to happen immediatly after removing an element?

evant
24 Jul 2007, 10:28 PM
Should just be able to call:



Ext.Element.garbageCollect();

cluettr
25 Jul 2007, 5:24 AM
Thanks Evant. Would this work asyncronously? In other words if I was to garbage collect and then during the collection recreate a div could the new div be created before the garbage collection is complete? Not sure if that is something you may be able to answer.

evant
25 Jul 2007, 6:06 AM
Looked at the source, garbageCollect runs synchronously.

The calls are made by Ext on a timer:



El.collectorThreadId = setInterval(El.garbageCollect, 30000);

pluesch0r
8 Aug 2007, 12:02 AM
Right now, I'm running into the same problem as animal - I've got a grid that I'm creating via Ajax; by executing the Ajax code twice, the old grid gets overwritten with the new grid .. but all the helper elements stay in the DOM.

Cheers,
Martin

cluettr
24 Aug 2007, 4:27 PM
Does the garbagecollection function only clean up Ext elements or does it do everythign in the dom?

GalaxySong
28 Aug 2007, 1:40 AM
Will it somehow save us from Memory Leak?

xsbr
29 Aug 2007, 2:21 PM
Will it somehow save us from Memory Leak?

On IE isn't possible avoid memory leak... There are four days that I'm trying to destroy memory leak no IE, but I couldn't...

Is possible reduce it... look at my thread:
http://extjs.com/forum/showthread.php?t=11810

krause
1 Dec 2010, 2:39 PM
Hi, I see this thread is quite old but it was the best existing thread I found.
Any updates for Ext 3.x?
What are the guidelines for correctly disposing of Components in order to allow for garbage collection and to prevent memory leaks?
Somebody recently asked me about this because they have quite a big Ext application all served through a single HML page and over time it consumes the memory. This is on Firefox (without firebug enabled).
I don't have a specific case, but rather I was looking for some guidelines regarding how to correctly dispose of components in the lines of "make sure you unregister all listeners that subscribed to events fire by the component you want to dispose" or "make sure you remove all records from the store"...(of course I'm making this up and is probably not correct).
I also see there are new (for Ext 3) autoDestroy config attributes for such things as stores and components, but haven't used them.

Any information will be greatly appreciated.

dan_b
1 Dec 2010, 4:24 PM
rather I was looking for some guidelines regarding how to correctly dispose of components in the lines of "make sure you unregister all listeners that subscribed to events fire by the component you want to dispose" or "make sure you remove all records from the store"...(of course I'm making this up and is probably not correct)..

Me too.. just about to push my first "one-big-page" ExtJS app into production...

Jamie Avins
1 Dec 2010, 5:13 PM
The garbage collector had some love back in the 3.1.x+ timeframe and does a better job at cleaning up various dom nodes that get orphaned as well as flushing out the central hash used to track events, pseudo expandos (Element.data), etc. Cleaning up you stores if they are no longer used is always important. Unregistering listeners is always a good idea if you hook into the component lifecycle, and never leave direct dom references

Eric24
9 Jan 2011, 8:33 AM
@Jamie: It would be really useful to see an "expansion" of your comments. Something like a quick overview with some examples of what to do and what to avoid to minimize leaks in Ext code.

richgoldmd
19 Jan 2011, 3:43 PM
I second Eric's motion...