View Full Version : Destroying objects: Large App : reduce memory consumption

18 Feb 2011, 8:05 AM
Is there a good resource or opinion on how and when to destroy rendered objects to save memory.

I have a pretty large application and it takes up a lot of memory. I am no memory expert and assume this is being taken up by all the data/JSON stored in my application.

Is it best proactice to destroy objects when moving off a tab/panel into another panel in efforts to optimize memory use by the browser?

18 Feb 2011, 8:19 AM
General rule: Destroy components that are hidden and won't be used often.

Note: Stores are not components, so they don't automatically get destroyed when you destroy the component that uses them (see the autoDestroy config option).

18 Feb 2011, 8:57 AM
Is it a correct assumption that the many dataloads in my app could be eating up the memory, or are Panels and Grids going to take up more?

I have a bunch of data that is redundantly loaded for lookup combo's and I load a lot of the same data for different grids, just present it in a different way. Looks like to me that the new Model feature in Ext4 will become EXTREMELY useful for me as I can load that data once and then use the local model.

It might be worth waiting and re-coding my data to Models than recoding to destroy objects. Opinion?

18 Feb 2011, 9:16 AM
What exact feature of Ext 4 are you referring to?

Most of this can be accomplished with Ext 3 too.

18 Feb 2011, 9:25 AM

referring to the ability to register Models.

I am a home-grown programmer so not sure how to do this in Ext3. So my various components all rebuild their own store, even if it is the same data.

18 Feb 2011, 9:45 AM
That's still the same in Ext 4.

You can use the same store for multiple components, as long as the components don't modify (e.g. filter) the store.

Alternatively, you can load multiple stores with the same data (uses more memory, but stores can be modifies separately).

18 Feb 2011, 10:00 AM
Maybe I am misinterpreting Ext4?

I guess I am doing it correctly as I filter/Manipulate the stores. From what you are saying here as I understand it, I would then HAVE to create a new store for each object. Therefore to save on memory (and perhaps an impact to performance) I would destroy the objects not in use (and set their stores to destroy with them) and reload them when needed, thus reloading the data.

What I read/understand from the Ext4 blog post is that I can create a model that pulls a chunk of data then I can use that model to create multiple stores and views of data for my various component. By loading the model with all the data I need, my stores are quicker because the data is now local in the model. Is that it in a nutshell?

To me that means that everytime i switch a panel with similar datasets, the store is querying the model and not re-pulling the data from my MySQL DB every time which increases data load times.

Am I over-thinking it here? Am I focused in the right direction concerning memory use?