Memory leak report lazarus / 21-General ---------------------------------------------------------------------- user5 · 2021-07-14 23:35 Could someone explain the leak report shown below and tell me if something is wrong and if so then what to look for in the code? The leak report had the word "Error" at the top left corner of the report. 599327 memory blocks allocated 599327 memory blocks freed 0 unfreed memory blocks : 0 True heap size: 229376 True free heap: 229264 Should be: 229376 ---------------------------------------------------------------------- user5 · 2021-07-15 00:11 For an experiment I made all the code in form1.show inert with {} characters, ran the program and then shut it down without doing anything and I got the following error report: 17337 memory blocks allocated 17337 memory blocks freed 0 unfreed memory blocks : 0 True heap size: 393216 True free heap: 393104 Should be: 393216     I then did another experiment by creating a new Lazarus program that does nothing at all except to show a form and I got the following Error report: 569 memory blocks allocated 569 memory blocks freed 0 unfreed memory blocks : 0 True heap size: 229376 True free heap: 229264 Should be: 229376     What gives? I get an error report for a new program that does nothing? The reports above seem to confirm what you say.     Anyway, thanks for your reassurance. It puts my mind at ease. ---------------------------------------------------------------------- dbannon · 2021-07-15 07:00 User5, are you worried about the numbers presented or the fact that you do get an "Error Report" ? If Heaptrc is turned on (Project Options -> Debugging) you will always get such a report, its unfortunate that its labeled "Error", its not an error, its just informative. You would never ship a product to end users with HeapTrc turned on, apart from the so called Error message, it slows things down significantly. As do the other debugging things ... Davo ---------------------------------------------------------------------- Zvoni · 2021-07-15 07:08 If you use heaptrc, you shouldn't use any other Memory-Manager (e.g. cmem) ---------------------------------------------------------------------- PascalDragon · 2021-07-15 07:13 Quote from: user5 on July 15, 2021, 02:11:46 am    What gives? I get an error report for a new program that does nothing? The reports above seem to confirm what you say.     Anyway, thanks for your reassurance. It puts my mind at ease. That is part of the initialization before heaptrc takes over. As long as 0 unfreed memory blocks is 0 and no double frees are reported all is well. ---------------------------------------------------------------------- Kays · 2021-07-15 10:06 Quote from: dbannon on July 15, 2021, 09:00:21 am[…] [it is] unfortunate that [it is] labeled "Error", [it is] not an error, [it is] just informative. […]Just for understanding: It’s (presumably) labeled “error” in Lazarus because heaptrc writes to stdErr (the standard error output stream). If you insertCode: 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)}                setHeapTraceOutput(output);        {$endIf}into your program you will probably see a different label. Confer setHeapTraceOutput documentation and heaptrc on the wiki. ---------------------------------------------------------------------- user5 · 2021-07-15 12:13 Thanks for the responses. What you all say is good stuff to know.     I disabled the leak check option after I was done with the testing. ---------------------------------------------------------------------- avra · 2021-07-15 12:15 Quote from: user5 on July 15, 2021, 02:11:46 amI get an error report for a new program that does nothing?There is a way to enable leak report only when leak is really found. Just look at https://wiki.freepascal.org/heaptrc.