[fpc-pascal] Monitoring memory usage
Mattias Gaertner
nc-gaertnma at netcologne.de
Wed Nov 10 09:53:29 CET 2004
On Wed, 10 Nov 2004 08:46:21 +0100
Florian Klaempfl <F.Klaempfl at gmx.de> 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 - fpc-pascal at lists.freepascal.org
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list