Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Instruments: peak RAM of iPhone apps running in Simulator?

Is Activity Monitor (a.k.a. Memory Monitor) the only tool in Xcode Instruments that can measure the total app RAM usage of an iPhone app running in Simulator? Just that line showing momentary wired RAM?

And how accurate is that versus iPhone hardware, especially given OSX paging i/o to VM?

I'm seeing 7-8MB wired RAM figures for just the default Xcode iPhone project templates (other than OpenGL) compiled and running. At the same time Object Allocations shows well under 1MB for all objects.

like image 618
MemoryFoam Avatar asked Feb 27 '23 17:02

MemoryFoam


2 Answers

Nope, there's a much better way to do it.

Go to the Run menu and select Run with Performance Tool then Object Allocations.

This will start Instruments and will show RAM usage. It's also useful for detecting memory leaks if you choose Leaks instead of Object Allocations.

like image 123
David Kanarek Avatar answered Apr 08 '23 16:04

David Kanarek


I would agree, since the Simulator is just an "API simulator", the behavior you see is going to be at least somewhat dependent how OS X manages memory. And the restrictions are obviously different, for example you can exceed 128 MB of ram, or even 256 MB, which obviously isn't possible on any current iPhone or iPod Touch (at least, as of this writing...).

I've still found it useful in OpenGL for making sure textures and other items are properly deallocated, but beyond that, it's just a rough guideline.

However, if you want to see memory usage on device, there's a simple enough solution. Just target Device in Xcode, and go to Run > Run with Performance Tool > Object Allocations, then the build will be sent to the device and the Object Allocations tool will pop up next to Xcode and show on device memory usage.

like image 22
Jazon Avatar answered Apr 08 '23 16:04

Jazon