Re: Stack space usage
Knut St. Osmundsen <bird <at> anduin.net>
2006-12-08 17:47:21 GMT
James Moe wrote:
> Is there a way to monitor the current stack space within a program? And,
> as a bonus, the heap and shared memory?
The best way to monitor stack usage is by coloring (memset()) the stack
and check how much of it is untouched. You can get the stack top/bottom
addresses from DosGetInfoBlocks(&pTib, &pPib); pTib->tib_...stack.
I don't quite recall if there is a heap api for querying the amount
memory it currently uses. grep -e 'heap.*stat' might find something...
As for shared memory, there you have to ask OS/2, which means using the
kernel debugger or Theseus (former is difficult, the latter I'm not very
familiar with I'm afraid).
> I found getrusage() in <sys/resource.h> but the linker complains that
> there is no object.
I don't think we've got a working getrusage() yet.