Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 828
Lana Miller Avatar asked Oct 10 '22 07:10

Lana Miller


1 Answers

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.

like image 121
Swift Dev Journal Avatar answered Oct 13 '22 09:10

Swift Dev Journal