How capture app memory usage/leaks

I wonder if it is possible to capture app memory usage/leaks while it is running, especially when a released version is running. Thanks.

The tools are in Instrument.


What do you mean by "released version is running" ?

Accepted Answer

>especially when a released version is running

Not sure it matters...a leak is leak and if you have something actionable, the tools should be able to help..or are you saying you've done that and the testbed app came up clean?

To confirm that process, see https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/FindingLeakedMemory.html


Is there a specific issue you're wrestling with in a release app otherwise? Perhaps if you explain, someone can offer suggestions, etc.

The OP is asking about adding code to monitor memory usage in an app release that's being run by customers. In this scenario, Instruments is not an option.


I'm not aware of any macOS APIs that can help with this. It might be possible to drop down to the Unix level to gather useful information. For example, see the "vm_stat" command line tool (https://developer.apple.com/library/content/documentation/Performance/Conceptual/ManagingMemory/Articles/VMPages.html), which could be run as a NSTask (Obj-C) or Process (Swift) child process. There may be equivalent Unix system functions that return this information, but that's not an area I'm familiar with.

Yes, but if there is a memory leak, it should occur also in development version, isn't it ? And it is safer than waiting for detection in released version.

How capture app memory usage/leaks
 
 
Q