19

I've noticed in the following post that you can get a stack trace out of FastMM to show what appears to be where an object was allocated:

How to track down tricky memory leak with fastMM?

I can't find any information on how to enable this in Delphi 2009, though.

I have set ReportMemoryLeaksOnShutdown to true so I get the basic report, but how do I get the stack trace report?

Community
  • 1
  • 1
Jamie
  • 3,150
  • 2
  • 26
  • 35

4 Answers4

43

The internal Delphi version of FastMM doesn't support stack traces.

If you want to log the memory leak stack traces, you have to:

  • download the full version of the FastMM library

  • include it as the first unit in your project:

    program YourProject;
    
    uses
      FastMM4, // <--
      SysUtils,
      Forms,
      ...
    
  • enable the FullDebugMode option in FastMM4Options.inc

  • set Map file to Detailed in the linking project options (the FastMM_FullDebugMode.dll processes the .map file)

  • add the FastMM_FullDebugMode.dll in your binary (or Windows System32) directory

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
ulrichb
  • 19,610
  • 8
  • 73
  • 87
  • 1
    FastMM_FullDebugMode.dll can also be stored in the Windows system directory. – gabr Jul 15 '09 at 10:04
  • 3
    on my 64 bit windows I had to copy it to: `C:\Windows\SysWOW64` – TmTron Oct 10 '12 at 14:24
  • I have done all of the above, but still not working for me. I use Delphi XE4 so symbol reference info is "reference info". Everything enabled in debugging. – Tom May 05 '21 at 10:20
7

You may also want to check out Jeremy North's FastMM4 Option setting program. It's just a bit easier than editing the inc FastMM4Options.inc file directly. Here's the link:

FastMM4 Options Interface Blog Post

MarkF
  • 1,616
  • 1
  • 17
  • 27
5

In addition, Francois Gaillard presented on CodeRage II a session called Fighting Memory Leaks for Dummies and deals specifically with FastMM. It is listed under the CodeRage II replays at thursday, November 29, 2007, 9.45am - 10:45am.

http://edn.embarcadero.com/article/37498

Regards, Erwin

Erwin
  • 1,896
  • 1
  • 11
  • 17
3

You can also see this and this for more detailed description, than ulrichb's reply.

And don't forget to enable "Use Debug DCUs" option ;)

Alex
  • 5,477
  • 2
  • 36
  • 56
  • "Use Debug DCUs" is optional and not directly related to FastMM's debugging capabilities of your OWN source code. – Gabriel Jun 04 '21 at 10:33