[fpc-pascal] TFPCHeapStatus miscalculations in 2.3.1

Seth Grover sethdgrover at gmail.com
Tue Aug 11 14:44:08 CEST 2009

I haven't logged a bug because I haven't yet figured out the steps to
exactly reproduce this, but I've been seeing something strange since
I've started using 2.3.1.

I have a thread pool in my application which gets assigned to run a
"job" by the user, does so, and then waits until it's called on again
to run another job. Since 2.3.1 gives a different heap to each thread,
I've added debugging code to periodically log the heap status returned
by GetFPCHeapStatus. At first, everything starts out fine:

0xB0A93BB0 heap status: cu=1456, cs=786432, cf=784976, mu=30720, ms=1048576
0xB0691BB0 heap status: cu=1456, cs=786432, cf=784976, mu=14080, ms=1048576
0xAFE85BB0 heap status: cu=1456, cs=786432, cf=784976, mu=30720, ms=1048576

Notice that "current size" minus "current free" equals "current used",
just like you'd expect.

After running for a few hours though, look at my numbers:

0xB0287BB0 heap status: cu=4294952816, cs=786432, cf=800912,
mu=4294967280, ms=5144576
0xAFA83BB0 heap status: cu=4294873136, cs=1146880, cf=1241040,
mu=4294967280, ms=5603328
0xB22C1BB0 heap status: cu=4294950256, cs=950272, cf=967312,
mu=4294967280, ms=5570560
0xB26CABB0 heap status: cu=4294956896, cs=983040, cf=993440,
mu=4294967280, ms=5570560
0xAF681BB0 heap status: cu=4294885088, cs=917504, cf=999712,
mu=4294967280, ms=5603328
0xAF27FBB0 heap status: cu=4294844176, cs=1179648, cf=1302768,
mu=4294967280, ms=5603328
0xB1EADBB0 heap status: cu=4294963824, cs=950272, cf=953744,
mu=4294967280, ms=5570560
0xB3EE6BB0 heap status: cu=4294956896, cs=950272, cf=960672,
mu=4294967280, ms=5570560

One by one, over time, the "current free" becomes *greater* than the
"current size", so the calculations are all screwy (current used is
negative, etc.).

Does anyone know about changes to this which could cause this problem?
It's rather annoying... I know the each heap isn't really using 4.2
gigabytes, but I wish the numbers were accurate.


This email is fiction. Any resemblance to actual events
or persons living or dead is purely coincidental.

Seth Grover

More information about the fpc-pascal mailing list