New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Question on calculating memory used in a program


Post Reply New Thread Subscribe

 
Thread Tools
catsophie

 
Member Since: Dec 21, 2007
Posts: 1
catsophie is on a distinguished road

catsophie is offline
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!!!
QUOTE Thanks
Del

 
Member Since: Dec 24, 2006
Location: N. Ireland
Posts: 901
Del has a spectacular aura about
Mac Specs: Mac Pro 2xQuad core 2.8GHZ

Del is offline
Maybe you have a memory leak or two in your code?
QUOTE Thanks
Exolon

 
Member Since: Nov 20, 2007
Location: Dublin, Ireland
Posts: 9
Exolon is on a distinguished road

Exolon is offline
From the manpage for top:
Quote:
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
QUOTE Thanks

Post Reply New Thread Subscribe


« Question for the Coders out there | How to upgrade gcc 3 to gcc 4 intel mac »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Memory Question (Using PC Memory in Mac Pro) dj_hype Switcher Hangout 4 12-17-2007 05:14 PM
Quick Memory Question macbookdabest Apple Notebooks 1 08-05-2007 07:38 PM
How much RAM is enough? misskool Apple Notebooks 43 05-05-2005 03:31 PM
Power PC G3 Memory question Malibu Other Hardware and Peripherals 1 10-13-2003 08:54 AM

All times are GMT -4. The time now is 08:26 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?