Question on calculating memory used in a program

Joined
Dec 21, 2007
Messages
1
Reaction score
0
Points
1
My question is why my calculation on memory usage is much different from the VSIZE shown in "top" command?

I calculated memory usage of my c program, compiling with gcc-4.0.1 on a MacPro. The funny thing is that my calculation shows about 40MB maximum memory usage, but the largest VSIZE in "top" command for this program is about 300MB. I double-checked my calculation and was sure that it is correct. My friend told me that it might be due to gcc's memory management strategy, which might not collect garbage as long as there is memory available. It might be true, since I dynamically allocate and release a lot of memory.

Can anybody give me more suggestions? Thanks!!!
 

Del


Joined
Dec 24, 2006
Messages
901
Reaction score
15
Points
18
Location
N. Ireland
Your Mac's Specs
Mac Pro 2xQuad core 2.8GHZ
Maybe you have a memory leak or two in your code?
 
Joined
Nov 20, 2007
Messages
9
Reaction score
0
Points
1
Location
Dublin, Ireland
From the manpage for top:
VSIZE(delta) Total address space allocated, including shared pages.
...
RSIZE(delta) Total resident memory size, including shared pages.
I think you're looking for RSIZE :)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top