Heap dump by heaptrc unit on Windows lazarus / 12-Debugger ---------------------------------------------------------------------- ricardo.consolo · 2017-03-01 12:51 Hi. When in debug mode (Windows 7 32 bits), I got this message when closing the application: --------------------------- Error --------------------------- Heap dump by heaptrc unit 9426 memory blocks allocated : 2495279/2522280 9426 memory blocks freed     : 2495279/2522280 0 unfreed memory blocks : 0 True heap size : 294912 True free heap : 294832 Should be : 294912 --------------------------- OK  --------------------------- The same application does not show that on Linux (Centos 6 32 bits). Any clue? Thanks. ---------------------------------------------------------------------- howardpc · 2017-03-01 13:15 Perhaps on Linux the heaptrc output is being sent to a nonexistent or hidden window, or maybe your Linux compilation setup is not set to generate heaptrc output at all. ---------------------------------------------------------------------- Ondrej Pokorny · 2017-03-01 13:57 Linux sends it to the standard output. ---------------------------------------------------------------------- avra · 2017-03-01 14:33 Have you tried to uncheck "Use Heaptrc unit" in Project options / compiler options / debugging ? ---------------------------------------------------------------------- Thaddy · 2017-03-01 15:52 And fortunately heaptrc also reports there's not much wrong with your code?  That memory will be free'd. If you want to use the heaptrc unit and keep it (only with -gh,not as an include in the uses clause)  there's also the option to compile with UseHeapTrace:= False. Which skips the report. But make sure that you did not add heaptrc to a uses clause anywhere yourself!. See the recent wiki. http://wiki.freepascal.org/heaptrc Avra's pointer is correct by the way: that selects or un-selects -gh for you. ---------------------------------------------------------------------- ricardo.consolo · 2017-03-01 21:05 Thanks for the info. I have checked them all and got it working. FYK, Linux output happens only when running the app from the terminal. Also, there was a bad destroy method in my code that I fixed. Thanks. ---------------------------------------------------------------------- michaelthuma · 2017-11-17 14:52 View-Debug Windows - Console Output Quote from: ricardo.consolo on March 01, 2017, 10:05:55 pmThanks for the info. I have checked them all and got it working. FYK, Linux output happens only when running the app from the terminal. Also, there was a bad destroy method in my code that I fixed. Thanks. ---------------------------------------------------------------------- HenrikErlandsson · 2026-07-01 22:24 This persists. I have no memory leaks, but always get this dialog to close with 112 bytes diff (which will be freed). Obviously I don't want to uncheck Use heaptrc unit in Debug mode, because then I won't catch actual leaks. It appeared when I used the "Create Debug and Release modes". Before that, I had been debugging a lot, without it appearing on every program exit. I was using Dwarf 3 beta before creating debug and release modes, and after. It seems this is related to IDE/settings somehow. ---------------------------------------------------------------------- n7800 · 2026-07-01 22:57 Quote from: HenrikErlandsson on July 02, 2026, 12:24:27 amIt appeared when I used the "Create Debug and Release modes". Before that, I had been debugging a lot, without it appearing on every program exit. I was using Dwarf 3 beta before creating debug and release modes, and after. It seems this is related to IDE/settings somehow. By default, a new project is created in the "Default" build mode, which disables this checkbox. In "Debug" mode, it is enabled. You can leave debug mode (with all its other options) enabled, but disable this checkbox. Personally, I only enable it occasionally. Quote from: HenrikErlandsson on July 02, 2026, 12:24:27 amThis persists. I have no memory leaks, but always get this dialog to close with 112 bytes diff (which will be freed). If you create a new empty project and enable this checkbox (or create a "Debug" mode), will the 112-byte leak message persist? The leak could be in the units you're using (even the standard ones). By the way, what version of Lazarus and FPC are you using? ---------------------------------------------------------------------- n7800 · 2026-07-01 23:06 Quote from: HenrikErlandsson on July 02, 2026, 12:24:27 amThis persists. I have no memory leaks, but always get this dialog to close with 112 bytes diff (which will be freed). By the way, the report should indicate exactly where the leak is (that's the whole point). Does it indicate anything useful or just memory addresses? ---------------------------------------------------------------------- mas steindorff · 2026-07-02 01:59 in your project file add Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  {$if declared(UseHeapTrace)}  GlobalSkipIfNoLeaks := true; {$endif}    after  Application.Run; and before end. ---------------------------------------------------------------------- Bart · 2026-07-02 08:30 Quote from: HenrikErlandsson on July 02, 2026, 12:24:27 amThis persists. I have no memory leaks, but always get this dialog to close with 112 bytes diff (which will be freed). Obviously I don't want to uncheck Use heaptrc unit in Debug mode, because then I won't catch actual leaks. It appeared when I used the "Create Debug and Release modes". In my Debug build mode I have unchecked the option "Windows GUI application (-WG)" in Compiler Options -> Config and Target. This also allow mee to see debugln() output on the console. Bart ---------------------------------------------------------------------- Martin_fr · 2026-07-02 08:45 There are a number of possible questions/answers. First it says 0 bytes leaked so that is ok. If the question is the True heap difference => I vaguely recall having read that this is memory that gets allocated by the system unit before heaptrc is fully initialized. Therefore it does not get properly accounted... If that is so, then the presence and/or size of that gap may vary for different targets, as the system unit includes target specific code... If the question is: why do I get a popup on windows, but not on Linux... Linux always has StdOut (even if it goes to /dev/nil) Heaptrc itself prints to stdout (or stderr, but I think stdout). That fails (runtime error on closed handle) on Windows for GUI apps. So the LCL (or LazUtils, something...) redirects this into a popup. Heaptrc iirc always prints a message. Either that there is a leak, or that there is not. So on Windows you do get that popup (unless you redirect heaptrc to a file, or silence it otherwise). On Linux it just prints to stdout, never mind where that goes.