Where is my memory getting consumed

流过昼夜 提交于 2019-12-11 05:39:18

问题


alt text http://img263.imageshack.us/img263/1880/leak.jpg Here is My problem. If you see there is no memory leak but still I get the memory leak for general block as shown. When I click it it gives me the following details where memory leak is due to quartz core. I dont know where I am going wrong since I am not able to see any leaks in the leak bar.

alt text http://img263.imageshack.us/img263/6813/leak2.jpg


回答1:


Bear in mind that the reason you see a 'leak' might be objects allocated to an AutoRelease pool. Libraries such as Three20 are particularly fond of this for image caching. If that is the case, the memory in question won't be released until there is a direct need for it (i.e. autorelease drain).

If you keep using your app, do you see a steady memory use climb, until a crash? Or do you see it like a sawtooth - i.e. going up, then suddenly down, then back up again?




回答2:


This looks like a case of an autorelease pool expanding and never draining. Hard to recommend anything without knowing about the particulars of your app (does it use multiple screens and tables or is it a single pane utility or game, etc.)

What you may consider doing is at logical points in your app -- for example when performing a single task -- create a new autorelease pool and use it only for the duration of that task, then release the pool. This will help keep your total memory down and give you better control over resources.

Also, if the app uses multiple view controllers, for example if you're bringing up a modal view or cascading treeviews, you can create the controller for the new view but then set a delegate on the viewcontroller that gets notified when the work is done so you can dispose of the whole controller and view instead of keeping it around.

Finally, if dealing with a lot of images you may want to create a sort of file-system-based caching mechanism with a fixed number of in-memory slots so you only keep data in memory that you absolutely need.



来源:https://stackoverflow.com/questions/1127792/where-is-my-memory-getting-consumed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!