Memory leak in Flex Charts
I have created a UI that displays 3-4 charts in the UI.
I notice the following
As soon开发者_运维问答 as these charts load up the IE memory shoots up to around 400 Mb which is understandable because some of these charts are like tables displaying upto a thousand rows.
I notice the more I refresh these charts the more IE memory increases.
From a simple walkthrough of the code multiple times, I couldn't find any leaks or any data structures who size was increasing. I am using Flex builder 2. I have a few questions:
- When does Flash free the memory ? Can I IE return that memory to the OS ?
- Is there a known memory leak in Flash ?
- What are the tools that could possible help me ?
- Does any programming best practise like making unused Objects explicitly as null, help ?
thank you very much.
I have one more question, it seems that the IE doesn't release any memory at all unless it is minimised ?
1) This article will explain everything about Garbage Collection (which is how managed languages take care of memory management). Basically you have no control of when it runs(there is a hack to force it but you shouldn't be using it)
http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
and this
http://blog.flexmonkeypatches.com/2007/03/28/flash-player-memory-management-and-garbage-collection-redux-2/
2) There shouldn't be a leak as long as you are ensuring that objects no longer needed are able to be garbage collected. That being said I am not familiar with Flex and perhaps there is a bug in the framework??? EDIT: There seems to be a lot of people who have problems with flex+ie and memory leaks.
3) System.totalMemory will at least help you see how much memory you are using. EDIT:Forgot to mention if you upgrade to Flex Builder 3 it comes with memory profiler tools
4) Yes, if you no longer need something setting it to null is good practise. Don't forget to remove any event listeners and make use of weak listeners where you can. If there is still a reference to something then it won't be marked for the garbage collector.
精彩评论