2

I've enabled memory leaks reporting:

ReportMemoryLeaksOnShutdown := True;

When I close my program I have a memory leak report like this :

enter image description here

But how to find exactly which objects was not released ?

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
zeus
  • 12,173
  • 9
  • 63
  • 184
  • Search through code where these leaks are and resolve them. – RBA Mar 22 '18 at 09:55
  • 2
    I don't understand the reason for those close votes. Tracking down memory leaks in your application is a is a problem directly related to programming. – CodesInChaos Mar 22 '18 at 10:05
  • It is a problem related directly to programming when you are making some effort in finding those leaks, and show attempts you've made in order to fix them – RBA Mar 22 '18 at 10:15

1 Answers1

6

You may use LeakCheck (or FastMM Full Debug Mode). LeakCheck outputs stack trace of the allocation (if enabled). It may even output dependency graph of the leak so you get the root cause.

LeakCheck way:

  • Download LeakCheck (you may use Delphinus)
  • Enable MAP file generation in compiler options
  • Add LeakCheck, LeakCheck.Setup.Trace to DPR uses section
  • Optional: add LeakCheck.Report.FileLog to uses as well (use with care as it scans the memory) - it generates .dot file that you can pipe through Graphviz to generate the leak graph
  • Run your app
  • Analyze the output
Honza R
  • 711
  • 7
  • 14