looking for a quick&dirty fix to remove memory leaks in freepascal

From: Falcon (noone_at_hotmail.com)
Date: 11/17/03


Date: Mon, 17 Nov 2003 12:50:10 +0100

Hi all,

I have made an application in freepascal (www.freepascal.org), which
uses the fgint.pas (http://triade.studentenweb.org/) for big integer
support. My problem is this: I use some iterative functions that
suffer from memory leaks. And fixing memory leaks when using fgint
functions is next to impossible because almost all internal functions
dynamically reserve/resize heap memory.

The weird thing is this: when I use Delphi 6, delphi cleans up the
heap after the function quits. So my question is this: Is there a
quick&dirty or standard method to clean op the mess a function creates
by allocating a lot of memory using getmem in freepascal. So it only
leaks when the actual function is in use. (all leaks are in local
var's)

If the heap is a linear growing chuck of memory, I think it could be
as easy as resetting the heap pointer to it's starting location. Or
maybe the os can be forced to release all allocated memory from a
specific point.

I'm really at loss here, so any help will be much appreciated.



Relevant Pages

  • Re: will I get Memory leak..
    ... dynamically assigned memory area will i get memory leak.. ... The problem with your code, on the other hand, is that your call to strcpywrites a null character to fp, which is one position past the end of the allocated memory. ... As a result of that error, the behavior of your entire program is undefined, which means that anything could go wrong A memory leak is very definitely a possibility from making that kind of mistake, but most of the other possible consequences of that mistake are much worse than memory leaks. ...
    (comp.lang.c)
  • Re: Memory Leak detection with HeapAlloc ... ?
    ... Your code won't detect memory leaks from HeapAlloc because it checks only those allocations taht were made via CRT. ... anyone knows of a solution where one could enable a page heap as described in the articles from sourcecode? ...
    (microsoft.public.vc.language)
  • Re: Memory Leaks?
    ... > not relinquish all memory back to the available pool for XP to use. ... To flesh this out a bit, memory leaks are a far greater problem in scripts ... When a script terminates, WSH runs a cleanup process that deletes the ... An object will be disconnected only after all references to it ...
    (microsoft.public.windowsxp.general)
  • Re: Garbage Colletor
    ... The Large Object Heap isn't compacted ... I'm specifically talking about memory leaks. ... A leak is a bug, but not all bugs are leaks. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Memory reclamation under Linux(es) ?
    ... kernel, though, since you're not complaining about any other app having ... memory leaks. ... ElectricFence that help you find memory leaks in C/C++ programs. ... you're interested in finding/fixing the leaks in Firefox 2, ...
    (comp.os.linux.misc)