Lana Miller
Lana Miller

Reputation: 1141

How do you see the specific methods responsible for memory allocation in XCode Instruments?

I've been asked to try and reduce memory usage in an app's code I have been given. The app runs fine in the simulator but on the device it is terminated or something, when debugging it enters a 'Paused' state and the app closes on the device.

When running instruments I discovered leaks, fixed them, however there is a large amount of allocation going on. Within a few seconds of launch the instruments allocation trace shows 1,021 KB for 'Malloc 16 Bytes'. This is essentially useless information as is, I need to see where the memory is being allocated but I can't seem to find anything useful. All i can get for a deeper inspection is that 'dyld', 'libsystem_c.dylib', 'libCGFreetype.A.dylib' etc are allocating a lot, but the responsible caller is never a recognizable method from the app source.

How can I see what methods are causing the most allocations here? I need to get this usage down! Thank you

Upvotes: 5

Views: 2928

Answers (2)

Swift Dev Journal
Swift Dev Journal

Reputation: 20088

Opening the extended detail view will show the call stack for memory allocations. Choose View > Extended Detail to open the extended detail view.

Switching to the call tree view will help you find where you are allocating memory in your code. Use the jump bar to switch to the call tree view.

Upvotes: 4

smparkes
smparkes

Reputation: 14083

1MB is no big deal. You can't do much in terms of throwing up a full view without using 1MB.

There's a good video from WWDC 2010 (http://developer.apple.com/videos/wwdc/2010/) that covers using instruments to analyze memory use. Title is Advanced Memory Analysis with Instruments. There may be an updated video from 2011.

Upvotes: 0

Related Questions