🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by Mike Knoblock Thu, 09 Aug 2007 18:16
Memory leaks and GetHeapStatus()
#1471
Author: Mike Knoblock
Date: Thu, 09 Aug 2007 18:16
34 lines
2516 bytes
I have a very large client application that appears to have a memory 
leak under certain conditions. The symptom is that Windows Task Manager 
reports increasingly high MemoryUsage over the course of several days to 
the point where the machine becomes sluggish or the application shuts 
down.

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.  Specifically, THeapStatus.TotalAllocated stays the same 
(around 36M) once it settles down but TM MemoryUsage continues to climb.

I'm assuming that anything I do programatically, such as create new 
forms, allocate blocks of memory, etc, all will be reflected in 
GetHeapStatus().  If this is not the case, I need some way to meter how 
much memory I'm consuming.

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, but when 
I refocus, Memory Usage doesn't return to 80M - it goes to some moderate 
value in between (15M or so).  I don't know if this behavior is telling 
me that TM Memory Usage is unreliable, or if I have some coding problem 
that contributes to this.

So:

1. Is Task Manager Memory Usage reliable?
2. Is GetHeapStatus() reliable, and if so, why doesn't it agree with TM?
3. Are there other tools to analyze my application's memory usage 
dynamically? For all I know, this could be a handle leak or something in 
my forms management that is at fault.

thanks for any ideas.

Mike
Re: Memory leaks and GetHeapStatus()
#1472
Author: danzer
Date: Thu, 09 Aug 2007 19:53
15 lines
1333 bytes
> 
> 1. Is Task Manager Memory Usage reliable?

No.

> 2. Is GetHeapStatus() reliable, and if so, why doesn't it agree with TM?
> 3. Are there other tools to analyze my application's memory usage 
> dynamically? For all I know, this could be a handle leak or something in 
> my forms management that is at fault.

I use Eurekalog.  There are others products that are compatible with 
Delph and C++Builder.


Danzer
Re: Memory leaks and GetHeapStatus()
#1473
Author: 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
Re: Memory leaks and GetHeapStatus()
#1496
Author: Dennis Jones
Date: Tue, 14 Aug 2007 21:29
15 lines
1454 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:46bb71aa$1@newsgroups.borland.com...
>
>> 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.

BoundsChecker no longer supports BCB (and hasn't for a long time), which is 
too bad because when it worked, it was very good.

- Dennis 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads