leakview

From Lazarus wiki
Revision as of 14:36, 26 March 2013 by BigChimp (talk | contribs)
Jump to navigationJump to search

Overview

Leakview allows fast navigation trough HeapTrc (and other?) leaks.

Usage

Leakview reads heaptrc output. For this to work, you'll need to enable heaptrc in your code:

Enabling heaptrc in Lazarus

To enable this in your Lazarus project: go to Project Options/Linking and in the Debugging section enable Use Heaptrc unit (check for mem-leaks) (-gh)

In your .lpr, in the beginning of your code, add

  {$IFDEF DEBUG} 
  // Assuming your build mode sets -dDEBUG in Project Options/Other when defining -gh
  // This avoids interference when running a production/default build without -gh

  // Set up -gh output for the Leakview package:
  if FileExists('heap.trc') then
    DeleteFile('heap.trc');
  SetHeapTraceOutput('heap.trc');
  {$ENDIF DEBUG}

to redirect the heaptrc output to file.

Enabling heaptrc in FPC

In FPC, you can specify -gh in your compilation option or include the heaptrc unit in your uses clause.

Then redirect the heaptrc output to file (instead of standard output). You can use similar code to the Lazarus code or alternatively, set the environment variable, e.g. on *nix:

export HEAPTRC="log=heap.trc"

or Windows:

set HEAPTRC="log=heap.trc"

Components Lazarus Debugging