Re: Logging physical/virtual memory usage of my app
Re: Logging physical/virtual memory usage of my app
- Subject: Re: Logging physical/virtual memory usage of my app
- From: Wade Tregaskis <email@hidden>
- Date: Mon, 24 Sep 2007 22:54:56 -0700
I have 24/7 that has a slow memory leak...
I would like regularly log the real Total memory size(VSIZE
) that my app is using.
What's the best way to retrieve this information from the System?
Well, naturally there's tools at the end-user level like ObjectAlloc,
MallocDebug and Shark, but if your app is frequently allocating &
deallocating memory, they're probably not going to be practical to
run over the time spans you'd like.
So, you can roll your own recorder in several ways. It depends,
naturally, on how you want to do so. "vmmap" will give you all sorts
of numbers, and could be logged periodically using a script, and
parsed and played with and all that. (there's also its cousin
vm_stat which provides general system-wide stats, if that's of interest)
You can also use top in logging mode, with a syntax something like:
top -l <maxiterations> -S -s <interval> -U <username> -c e
There's no way I'm aware of to have it just look at one process,
though you could pass the output through grep easily enough to filter
it.
If you want the information programmatically, you can include <mach/
mach.h> and then poke with such functions as task_info(), to get the
task_basic_info for your chosen task (you can get the necessary
task_t using task_for_pid(), defined in /usr/include/mach/
mach_traps.h). See http://web.mit.edu/darwin/src/modules/xnu/osfmk/
man/ for documentation.
Wade
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden