Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / CodeWarrior / January 2005



Tip: Looking for answers? Try searching our database.

top reports 50M RPRVT; MallocDebug says 2M?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bruce Horn - 18 Jan 2005 04:37 GMT
I'm trying to optimize the memory use of my Mach-O application
(CodeWarrior C++ application, using PowerPlant and now PPx).  My
application is very dynamic: lots of allocations and deallocations using
new/free in C++ and a few mallocs and NewPtrs thrown in here and there
as required.

When I am watching it run using MallocDebug, it looks like I am
appropriately deallocating objects that I don't need (i.e. no leaks).  
However, the longer I run, doing various memory-intensive tasks that
allocate and deallocate, the more private/resident memory I seem to be
using according to top.  One clue is MREGS which is quite large (290 at
this point; however, CodeWarrior is using 1355).  MallocDebug will say
that I'm using about 4MB of allocated space, while top will say that I'm
using 40-50M of private address space and hundreds of MB of total VM.  
Seems strange.

So, I am assuming that, although I am not using much real memory, it is
fragmented and the memory manager can't consolidate regions.

Is it a problem if the resident private address space size is large,
even if the application is not using the memory?  Is there a way to
force consolidation if possible?  I don't know the CW memory management
code that well, especially with respect to interaction with the Mach VM.  
Are there other memory allocator options that might be more well-behaved?

Hints and suggestions appreciated.

Thanks--

  Bruce

Signature

Bruce Horn, Chief Technical Officer, Marketocracy, Inc.

Stephen Davis - 18 Jan 2005 08:09 GMT
> I'm trying to optimize the memory use of my Mach-O application
> (CodeWarrior C++ application, using PowerPlant and now PPx).  My
[quoted text clipped - 11 lines]
> I'm using 40-50M of private address space and hundreds of MB of total
> VM.  Seems strange.

MallocDebug works by substituting its own allocator for the system
allocator.  It then saves stack crawls for your allocations, does
memory leak analysis, etc.  It uses a *LOT* of actual memory to do
this.  MallocDebug reports what your app is using (4MB) but the system
top tool sees what your app is using plus what MallocDebug is using
"under the covers" (40-50MB).

In short, believe MallocDebug and not top when you are running your app
with MallocDebug.

hth,
stephen
Bruce Horn - 19 Jan 2005 01:02 GMT
> > I'm trying to optimize the memory use of my Mach-O application
> > (CodeWarrior C++ application, using PowerPlant and now PPx).  My
[quoted text clipped - 21 lines]
> In short, believe MallocDebug and not top when you are running your app
> with MallocDebug.

Stephen,

That's a good point, but there is still something going on that is not
explained by the concept that MallocDebug is using a lot of memory.  In
my final (non-MallocDebug) version, I see very similar numbers from top;
not as huge but more than I'd expect given the sizes I see running
MallocDebug.

There used to be other allocators, like HeapManager, that could be
linked in instead of the system allocator.  Are there any other choices
that I should be considering?

Thanks--

  Bruce

Signature

Bruce Horn, Chief Technical Officer, Marketocracy, Inc.

Eric Albert - 19 Jan 2005 06:17 GMT
In article
<outlawspam-EC01D4.17022918012005@newssvr14-ext.news.prodigy.com>,

> > > I'm trying to optimize the memory use of my Mach-O application
> > > (CodeWarrior C++ application, using PowerPlant and now PPx).  My
[quoted text clipped - 21 lines]
> > In short, believe MallocDebug and not top when you are running your app
> > with MallocDebug.

> That's a good point, but there is still something going on that is not
> explained by the concept that MallocDebug is using a lot of memory.  In
> my final (non-MallocDebug) version, I see very similar numbers from top;
> not as huge but more than I'd expect given the sizes I see running
> MallocDebug.

How are you measuring memory allocation in MallocDebug?

Also, you may want to look into the heap, malloc_history, and leaks
command-line tools.

-Eric

Signature

Eric Albert         ejalbert@cs.stanford.edu
http://outofcheese.org/

Sean McBride - 22 Jan 2005 23:05 GMT
In article
<outlawspam-EC01D4.17022918012005@newssvr14-ext.news.prodigy.com>,

> There used to be other allocators, like HeapManager, that could be
> linked in instead of the system allocator.  Are there any other choices
> that I should be considering?

You might look up "DebugNew" and I think Howard Hinnant made a
replacement for new/delete for debugging also.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.