Sign in Join

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

Mailing lists / fpc-pascal / 2012-01

Best practice for getting heap usage summary

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Mark Morgan Lloyd

What is considered "best practice" for getting a summary of heap usage, in a single-threaded program which doesn't need to be Delphi-compatible?

In Delphi programs that have had to run for an extended period I've used AllocMemCOunt() and AllocMemSize(). What's the best way of getting something comparable for FPC- THeapStatus.TotalAllocated etc.?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mattias Gaertner
to Mark Morgan Lloyd
Show quoted text 6 lines
What is considered "best practice" for getting a summary of heap usage, in a single-threaded program which doesn't need to be Delphi-compatible? In Delphi programs that have had to run for an extended period I've used AllocMemCOunt() and AllocMemSize(). What's the best way of getting something comparable for FPC- THeapStatus.TotalAllocated etc.?

Maybe you mean GetFPCHeapStatus

http://lazarus-ccr.sourceforge.net/docs/rtl/system/getfpcheapstatus.html

There is also the Delphi compatible GetHeapStatus, but only for 32bit.

Mattias

Reply by email

Mark Morgan Lloyd
to Mattias Gaertner
Mattias Gaertner wrote 15 lines
On Thu, 19 Jan 2012 09:06:46 +0000 Mark Morgan Lloyd wrote: > What is considered "best practice" for getting a summary of heap usage, > in a single-threaded program which doesn't need to be Delphi-compatible? > > In Delphi programs that have had to run for an extended period I've used > AllocMemCOunt() and AllocMemSize(). What's the best way of getting > something comparable for FPC- THeapStatus.TotalAllocated etc.? Maybe you mean GetFPCHeapStatus http://lazarus-ccr.sourceforge.net/docs/rtl/system/getfpcheapstatus.html There is also the Delphi compatible GetHeapStatus, but only for 32bit.

Yes, I was assuming that was necessary to get the THeapStatus block. I take it that you're confirming that this is the way to get the info, and that there aren't direct RTL calls.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Jonas Maebe
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 10 lines
Mattias Gaertner wrote: > Maybe you mean GetFPCHeapStatus > http://lazarus-ccr.sourceforge.net/docs/rtl/system/getfpcheapstatus.html > There is also the Delphi compatible GetHeapStatus, but only for > 32bit. Yes, I was assuming that was necessary to get the THeapStatus block. I take it that you're confirming that this is the way to get the info, and that there aren't direct RTL calls.

The above is a direct RTL call. But note that
a) it is buggy in case of multi-threaded programs: http://bugs.freepascal.org/bug_view_advanced_page.php?bug_id=14315 b) it won't contain any information at all if you use cmem or another memory manager that does not keep track of allocation information.

Jonas

Reply by email