fphttpapp suspect mem leak lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Чебурашка · 2022-02-10 09:30 Hello, I worked all nite to complete this great program, then I compiled it with "Use Heaptrc unit (check for mem-leaks) (-gh)" in Lazarus. 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  program project3; uses   fphttpapp; begin end. I get this: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  tt@debian:~/Documents/dev$ ./project3Heap dump by heaptrc unit75 memory blocks allocated : 72406/7259273 memory blocks freed     : 72350/725362 unfreed memory blocks : 56True heap size : 163840True free heap : 163456Should be : 163528Call trace for block $00007FCED20ECFC0 size 32Call trace for block $00007FCED20ECA80 size 24tt@debian:~/Documents/dev$ Is the leak real? ---------------------------------------------------------------------- howardpc · 2022-02-10 10:59 Of course the leak is real. heaptrc may not catch quite as many potential leaks as valgrind, but you can't argue with its simple arithmetic: your program allocated 75 memory blocks and did not free them all. For the reason why, I suppose you have to look at the initialization and finalization code of fphttpapp and see how your system handles that code. ---------------------------------------------------------------------- Чебурашка · 2022-02-10 11:09 Quote from: howardpc on February 10, 2022, 11:59:22 amOf course the leak is real. heaptrc may not catch quite as many potential leaks as valgrind, but you can't argue with its simple arithmetic: your program allocated 75 memory blocks and did not free them all. For the reason why, I suppose you have to look at the initialization and finalization code of fphttpapp and see how your system handles that code. Just to clarify, I did not create fphttpapp on my own, it is a library unit in fpc package fcl-web. packages/fcl-web/src/base/fphttpapp.pp My system is a "Linux debian 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux" ---------------------------------------------------------------------- wp · 2022-02-10 11:11 What is your Lazarus/FPC version, and your OS? I checked Laz-main/FPC- main, Laz 2.2/FPC 3.2.2, Laz 1.8.4/FPC3.0.4, and in none of them that memory leak is reported. I am on Windows, though. ---------------------------------------------------------------------- Чебурашка · 2022-02-10 11:20 Quote from: wp on February 10, 2022, 12:11:10 pmWhat is your Lazarus/FPC version, and your OS? I checked Laz-main/FPC-main, Laz 2.2/FPC 3.2.2, Laz 1.8.4/FPC3.0.4, and in none of them that memory leak is reported. I am on Windows, though. tt@debian:~/Documents/dev$ fpc -i Free Pascal Compiler version 3.0.4 Compiler date      : 2019/01/24 Compiler CPU target: x86_64 Supported targets (targets marked with '{*}' are under development):   Linux: Linux for x86-64   FreeBSD: FreeBSD for x86-64   Win64: Win64 for x64   Darwin: Darwin for x86_64   solaris: Solaris for x86-64 {*}   OpenBSD: OpenBSD for x86-64 {*}   NetBSD: NetBSD for x86-64 {*}   DragonFly: DragonFly for x86-64   iPhoneSim: Darwin/iPhoneSim for x86_64 Supported CPU instruction sets:   ATHLON64,COREI,COREAVX,COREAVX2 Supported FPU instruction sets:   SSE64,SSE3,SSSE3,SSE41,SSE42,AVX,AVX2 Supported inline assembler modes:   STANDARD   GAS   INTEL   ATT Recognized compiler and RTL features:   HEAP,INITFINAL,RTTI,CLASSES,EXCEPTIONS,EXITCODE,ANSISTRINGS,WIDESTRI NGS   TEXTIO,CONSOLEIO,FILEIO,RANDOM,VARIANTS,OBJECTS,DYNARRAYS,THREADING   COMMANDARGS,PROCESSES,STACKCHECK,DYNLIBS,SOFTFPU,OBJECTIVEC1,RESOURCES   UNICODESTRINGS Supported ABI targets:   DEFAULT Supported Optimizations:   REGVAR   STACKFRAME   PEEPHOLE   LOOPUNROLL   TAILREC   CSE   DFA   USERBP   ORDERFIELDS   FASTMATH   REMOVEEMPTYPROCS   CONSTPROP Supported Whole Program Optimizations:   All   DEVIRTCALLS   OPTVMTS   SYMBOLLIVENESS Supported Microcontroller types: This program comes under the GNU General Public Licence For more information read COPYING.v2 Please report bugs in our bug tracker on:                  http://bugs.freepascal.org More information may be found on our WWW pages (including directions for mailing lists useful for asking questions or discussing potential new features, etc.):                  http://www.freepascal.org lazarus is: 2.0.0+dfsg-2 (I think dfsg is debian packaging stuff) Date: 2019-03-01 tt@debian:~/Documents/dev$ uname -a Linux debian 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux Thank you for the help ---------------------------------------------------------------------- Чебурашка · 2022-02-10 13:31 Sorry guys it seems that this was a know bug in older versions. https://gitlab.com/freepascal.org/fpc/source/-/issues/33535