[Lazarus] Memory leak hunt request

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Sat Apr 26 12:08:25 CEST 2014


On 2014-04-26 10:31, Reinier Olislagers wrote:
> I'm often a bit dumb when it comes to memory management/memory leaks -
> probably because of my managed code experience (yes, excuses, excuses)...

>From my experience, develop your software from the ground up with
Heaptrc unit enabled (compiler option -gh). It is MUCH easier to fix a
memory leak the second you created it, compared to 6 months down the line.

As for your question about how to resolve them. Simply enable -gh, run
your app from a console window. Start simple. eg: Run the app, then
immediately exit. Do memory leaks occur? If so, analyse the heaptrc
output. Trace the line numbers and call stack. Go through the affected
code with a fine tooth comb. Fix and repeat the test. Did the leak count
reduce.

Once all "application startup" leaks have been fixed, move to another
dialog, and repeat the whole process. Yes, it's painful and boring as
hell. Hence my suggestion on starting development with -gh enabled and
it makes it much easier.

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/




More information about the Lazarus mailing list