[fpc-pascal] Widestring Questions

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Oct 26 21:37:57 CEST 2010


On 26 Oct 2010, at 21:28, Tobias Giesen wrote:

> Upon exit, the memory does seem to be freed correctly now according to
> heaptrc. But MacOS stops giving memory to the app after a while and 
> then it quits.
> 
> Could it be that the memory manager has been changed since FPC 2.2 and
> is now more susceptible to heap fragmentation?

It has been changed, but if anything it should be less susceptible to heap fragmentation.

> Could there be any allocations that bypass heaptrc?

Yes, if you call external code that uses libc's malloc() family of routines to allocate memory.

> The app is allocating hundreds of Megabytes of memory over time and I 
> still don't know how it is happening.

What you can try is
a) add "cmem" to the uses clause of your program, to change from FPC's default heap manager to the libc memory manager. If that solves the problem, it's probably a heap fragmentation issue
b) if that does not help (or not enough), disable heaptrc (but keep cmem) and run Valgrind's massif tool on your program. You can download Valgrind from http://valgrind.org/ and information about massif at http://valgrind.org/docs/manual/ms-manual.html


Jonas


More information about the fpc-pascal mailing list