Friday, April 16, 2010

Thanks a heap, Apple

I've been going through some tutorials for developing on the iPhone (and now iPad) and found this cool utility digging around the developer docs:

There's this cool little utility called "heap" in OS/X. If you find the pid (process id) of a running process and just run "heap PID" on the process, it will dump out how memory is allocated in the heap for that process.

The only two limitations are: you need to have access to that process, so you either have to do it on a process running as the user you are currently logged in or be running as root. Also, I think it has to be a native Objective C, C++, or maybe C binary.

It attempts to figure out what type of object each thing allocated in memory is, and breaks it up class. Included stats are total count, total size, average size, and if it can figure out what library the variables are coming from, it includes that too.

No comments: