Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-11

Monitoring memory usage

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Alan Mead

Is there an easy way to monitor memory allocations during a program run (for debugging purposes)?

Ideally, this would be some sort of hook into the memory manager rather than something like gdb because the program runs for hours.

A list of the calling subroutine (or line number) and the amount allocated/deallocated, that would be quite helpful.

I think I can trace most of the memory being allocated manually but I'd like an auditing mechanism to verify.

Thanks!

-Alan

Florian Klaempfl
to Alan Mead
Alan Mead wrote
Is there an easy way to monitor memory allocations during a program run (for debugging purposes)?

I guess the easiest is using the heaptrc unit and modifying it for your needs.

Show quoted text 17 lines
Ideally, this would be some sort of hook into the memory manager rather than something like gdb because the program runs for hours. A list of the calling subroutine (or line number) and the amount allocated/deallocated, that would be quite helpful. I think I can trace most of the memory being allocated manually but I'd like an auditing mechanism to verify. Thanks! -Alan _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Mattias Gaertner
to Florian Klaempfl
Show quoted text 7 lines
Alan Mead wrote: > Is there an easy way to monitor memory allocations during a program > run (for debugging purposes)? I guess the easiest is using the heaptrc unit and modifying it for your needs.

See lazarus: components/codetools/memcheck.pas
The include file (memcheck_laz.inc) contains the added features:

procedure CheckHeap;
procedure CheckHeap(const txt: ansistring);
procedure CheckHeapWrtMemCnt(const txt: ansistring);
procedure WriteGetMemCount(const txt: ansistring);
function MemCheck_getmem_cnt: longint;
function MemCheck_freemem_cnt: longint;
function MemCheck_getmem_size: longint;
function MemCheck_freemem_size: longint;
function MemCheck_getmem8_size: longint;
function MemCheck_freemem8_size: longint;

You may want to change the longints to int64.

Mattias

Show quoted text 23 lines
> > Ideally, this would be some sort of hook into the memory manager > rather than something like gdb because the program runs for hours. > > A list of the calling subroutine (or line number) and the amount > allocated/deallocated, that would be quite helpful. > > I think I can trace most of the memory being allocated manually but > I'd like an auditing mechanism to verify. > > Thanks! > > -Alan > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Alan Mead
to Mattias Gaertner

Thanks for everyone, I'll tae a

--- Mattias Gaertner wrote 65 lines
On Wed, 10 Nov 2004 08:46:21 +0100 Florian Klaempfl wrote: > Alan Mead wrote: > > > Is there an easy way to monitor memory allocations during a program > > run (for debugging purposes)? > > I guess the easiest is using the heaptrc unit and modifying it for your > needs. See lazarus: components/codetools/memcheck.pas The include file (memcheck_laz.inc) contains the added features: procedure CheckHeap; procedure CheckHeap(const txt: ansistring); procedure CheckHeapWrtMemCnt(const txt: ansistring); procedure WriteGetMemCount(const txt: ansistring); function MemCheck_getmem_cnt: longint; function MemCheck_freemem_cnt: longint; function MemCheck_getmem_size: longint; function MemCheck_freemem_size: longint; function MemCheck_getmem8_size: longint; function MemCheck_freemem8_size: longint; You may want to change the longints to int64. Mattias > > > > > Ideally, this would be some sort of hook into the memory manager > > rather than something like gdb because the program runs for hours. > > > > A list of the calling subroutine (or line number) and the amount > > allocated/deallocated, that would be quite helpful. > > > > I think I can trace most of the memory being allocated manually but > > I'd like an auditing mechanism to verify. > > > > Thanks! > > > > -Alan > > > > _______________________________________________ > > fpc-pascal maillist - > > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal