Sign in Join

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

Mailing lists / fpc-pascal / 2020-12

heaptrc unit troubles with New() & Dispose() calls

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

Are there any known issues with heaptrc unit via compiler parameters -gl -gh, when using New() and Dispose() to manually allocate and free memory.

I helped someone debug their code, finding and fixing a memory leaks, but the FPC memory leak output, after the application terminates, did not mention the actual method causing the memory leak. I used FPC 3.2 and the other person used FPC 3.0 - both under Linux for x86_64.

The method that had the memory leak was using New() and Dispose() for memory management. There was a try..except block and the exception block forgot to call Dispose() on the variable that was allocated.

Normally FPC is pretty good at pinpointing where a memory leak was caused, so I was just curious why it didn't work so well this time round.

Regards,
Graeme

Jonas Maebe
to Graeme Geldenhuys
Graeme Geldenhuys wrote
Are there any known issues with heaptrc unit via compiler parameters -gl -gh, when using New() and Dispose() to manually allocate and free memory.

No. New and Dispose eventually result in calls to plain getmem/freemem anyway.

Jonas

Graeme Geldenhuys
to Jonas Maebe
Jonas Maebe wrote
No. New and Dispose eventually result in calls to plain getmem/freemem anyway.

Thanks Jonas. I'll try and reproduce the original issue with a smaller example. It the issue still persists (can't determine the method causing the memory leak), I'll file a bug report.

Regards,
Graeme