I have an app that's very memory intensive...LOTS of image processing in Core Graphics routines and custom pixel processing routines.
I've been very careful with memory as far as I can tell, but the longer my app runs, I notice memory slowing rising in the Memory Report in Xcode 5. I've run it many times in Instruments and I don't see any leaks.
Any ideas on how to debug this or where I can look?
Thanks.
You can use instruments to see what is getting allocated and to look at the retain/release/autorelease lifecycle of an image and what the call stack is for each of them.
If you have memory growing without leaks you are still holding onto the memory somewhere.
Related
I can't find how to determine how much memory is in use by individual objects.
Using Xcode's visual memory debugger, the memory shown on the right side (circled red) is not how much memory the object is actually using.
Xcode allocation instruments seems to only show the entire heap and memory used by individual allocations, not objects as a whole.
Am I missing something? Is there anyway to see how much aggregated memory is used by individual objects?
In my app, I load the interactive meeting URL on wkWebView, but I've noticed that the allocated memory has been gradually increasing.
When the app starts, memory is around 22 MB, but memory increases by the second.
How can I stop my memory from gradually increasing over time?
https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/LaunchingInstruments.html
Try running your app in Instruments with the Leaks or Allocations filter to see what is causing your issues. Hopefully, that will lead you to the source of your memory leak(s).
Been trying to find this bug for days now with no solution. Developing a ios game uising swift and only UIKit. My app displays a lot of small images (about 70 a time). Some uianimations are running repeatingly. After a while my app show some performance lags (tested on a device). Xcode shows only 30MB of memory usage and about 97% CPU time used. Using instruments didnt really help (im not using a lot of memory anyway). How can I track this bug down, this seems so weird to me.
The problem is that using UIKit for such graphics is not the best solution, as it is working through CPU, not GPU. And this is the reason, why application is lagging.
The other reason for it to show only 30MB of memory used, as it does not show memory used for uncompressed images. When you display image on the screen, or use UIViews with drawRect:, it takes really a lot of memory.
When watching the debug graph in xcode 6 (and probably 5 too), when running my application the memory use continues to rise as I place more of a certain object on the screen and animate it's movement. It does not seem to decrease when I remove it. Once removed I believe there are no more references to them.
See screenshot:
http://i.stack.imgur.com/SnhbK.png
However when I use Instruments to try to identify what's going on, there's only around 12mb persisting, and Total Bytes continues to rise, as expected.
See screenshot:
http://i.stack.imgur.com/VBwce.png
Is this normal behaviour? What exactly is the graph in Xcode showing? Am I overlooking something?
In Instruments I have Allocation Lifespan set to All Allocations and Allocation Type set to All Heap and Anonymous VM for the screenshots above.
UPDATE
By running Instruments with Activity Monitor I was able to see that the "Real Memory" was increasing at the same rate as is displayed in Xcode. #Mark Szymczyk pointed out that OpenGL ES Texture memory allocations are not shown in the Allocations instrument.
By purging the texture cache with the following command in Cocos2D 3.1 at regular intervals, memory use consistently drops back down to around 18mb and begins increasing again as I add more sprites.
[[CCDirector sharedDirector] purgeCachedData];
Credits go to Mark Szymczyk for pointing me in this direction - thanks!
Looking at your screenshots, the Xcode graph is probably showing the equivalent of the Total Bytes column in your Instruments screenshot. When you remove an object, the persistent bytes will decrease, but the total bytes won't. That would explain why the memory use never goes down in the Xcode graph.
The Persistent Bytes column in Instruments is what you should be looking at to determine your app's memory usage.
In my situation I continuously enter one scene, than exit and so on... So Live bytes amount must be the same while reentering the scene, but it grows up by 3Mb on each enter.
I want to find memory that remains from previous scene. Memory Leak instrument shows no leaks.
How can I compare two "snapshots" of memory to highlight differences in allocations?
Previous scene snapshot:
After reentering:
approach it using Heapshot Analysis
Here's a great blog entry by bbum: When is a Leak not a Leak? Using Heapshot Analysis to Find Undesirable Memory Growth