🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1473

Re: Memory leaks and GetHeapStatus()

#1473
From: Remy Lebeau (TeamB)
Date: Thu, 09 Aug 2007 19:57
48 lines
2584 bytes
"Mike Knoblock" <mknoblock@gmail.com> wrote in message
news:46bb5a33$1@newsgroups.borland.com...

> I tried to use GetHeapStatus() to track local memory allocation
> along with my calls to NEW and DELETE, but it doesn't agree
> with the Task Manager.

Borland's memory manager allocates memory in larger chunks than what your
code actually requests, and deallocations are not released back to the OS
right away, either.

> Specifically, THeapStatus.TotalAllocated stays the same (around
> 36M) once it settles down but TM MemoryUsage continues to climb.

The THeapStatus.TotalAllocated value indicates the number of bytes you are
actually using in your code.  But what the TaskManager shows, and what the
memory manager uses internally, is virtual memory, which is reflected in the
THeapStatus.TotalAddrSpace value.

> I've also noticed that Task Manager will report large Memory Usage
> (say 80 M) that will drop to 1-2M when the application is minimized

That happens when the process's current working set of memory pages is
swapped out of system memory.  That is normal behavior to free system memory
for other programs to use.

> when I refocus, Memory Usage doesn't return to 80M - it goes
> to some moderate value in between (15M or so).

That is also normal behavior.

> Is Task Manager Memory Usage reliable?

Rarely.  Certainly not for troubleshooting leaks.

> Is GetHeapStatus() reliable, and if so, why doesn't it agree with TM?

It does.  You are just not looking at everything THeapStatus provides.

> Are there other tools to analyze my application's memory usage
> dynamically?

Are are many third-party profilers and analyzers available, such as AQTime,
MemCheck, BoundsChecker, etc.


Gambit
Technical Details
Message-ID: <46bb71aa$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <46bb5a33$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,b4f2e24dc905850e
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <46bb5a33$1@newsgroups.borland.com>
Subject: Re: Memory leaks and GetHeapStatus()
Date: Thu, 9 Aug 2007 12:57:07 -0700
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.29.61
Message-ID: <46bb71aa$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1186689450 75.83.29.61 (9 Aug 2007 12:57:30 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail