limelect 48 Posted July 19, 2022 (edited) D10.2.3 using FastMM4 I have the same problem as https://stackoverflow.com/questions/71178572/memory-leak-of-tidcriticalsection-create-in-idthreadsafe-pas Tried this suggestion https://www.viathinksoft.com/codelib/144 on create Any Idea? P.S I tried FREE_ON_FINAL as Remy suggested but I am not sure I compile/Build Indy with my project Edited July 19, 2022 by limelect Share this post Link to post
rvk 33 Posted July 19, 2022 Are you using TIdHttpServer? (In the other topic you showed some code with just TIdHTTP) How do you measure the leak? with just FastMM4 or MadExcept? The topic you linked to mentioned FastMM doesn't report the leak but MadExcept does. So how is this problem the same as mentioned in that topic? What exactly is your leak, how does it show and what (minimal) code can you provide which reproduces this? Share this post Link to post
limelect 48 Posted July 19, 2022 (edited) @rvk The leak is exactly in the first link Using fastmm4 A solution is on the second Edited July 19, 2022 by limelect Share this post Link to post
David Heffernan 2345 Posted July 19, 2022 It's as if you don't want people to help you. Share this post Link to post
Remy Lebeau 1394 Posted July 19, 2022 4 hours ago, limelect said: I have the same problem as https://stackoverflow.com/questions/71178572/memory-leak-of-tidcriticalsection-create-in-idthreadsafe-pas And? The problem is ...? 4 hours ago, limelect said: Tried this suggestion https://www.viathinksoft.com/codelib/144 on create Wow, that is a really dirty and ugly hack. That code is reading the machine instructions of TIdStack.DecUsage() at runtime trying to find where it accesses the global GStackCriticalSection variable, and then it dereferences that variable to get the address of the TIdCriticalSection object, and then register it with FastMM so it won't appear in leak reports. I don't see why that hack is necessary at all when Indy already does that registration during unit initialization when REGISTER_EXPECTED_MEMORY_LEAK is defined, which it is by default when FREE_ON_FINAL is not defined, and either HAS_System_RegisterExpectedMemoryLeak or USE_FASTMM4 are defined. 4 hours ago, limelect said: P.S I tried FREE_ON_FINAL as Remy suggested but I am not sure I compile/Build Indy with my project Yes, that is the correct solution. You have to recompile Indy for it to take effect. The simplest way would be to have your project refer to Indy's source files directly so they compile directly into the executable. If you have installed Indy into the IDE, you will have to recompile the installed BPLs instead. Share this post Link to post
limelect 48 Posted July 19, 2022 (edited) @Remy Lebeau I took your suggestion and BUILD indy 10 with {$DEFINE FREE_ON_FINAL} in the include Made sure I did compile (build) as I have all DCU in the indy directory And it did not help I am trying all kinds of solution that why Edited July 19, 2022 by limelect Share this post Link to post
Remy Lebeau 1394 Posted July 19, 2022 (edited) 3 hours ago, limelect said: @Remy Lebeau I took your suggestion and BUILD indy 10 with {$DEFINE FREE_ON_FINAL} in the include Made sure I did compile (build) as I have all DCU in the indy directory And it did not help Then you are likely not building with the DCUs you just compiled. Did you remove Indy from the IDE first? Did you update the IDE's search paths? https://github.com/IndySockets/Indy/wiki/Updating-Indy Also, which platform are you running your code on? The leaks you have showed are the intentional Indy leaks that should not be appearing on Windows, as they are "registered by pointer", as the dialog says. Edited July 19, 2022 by Remy Lebeau Share this post Link to post
limelect 48 Posted July 20, 2022 @Remy Lebeau I am with D10.2.3. I run my application on the IDE and see afterward the Indy DCU that before they weren't there so I guess my software uses the compiled INDY. (on the source Delphi directory). I did not remove INDY but I am sure I compiled with INDY DCU I made. Well not to bother anymore I will leave the problem as it is. It does not affect my program. OUT OF CURIOSITY it is this program https://limelect.com/downloads/document-projects/ and thanks again Share this post Link to post
Remy Lebeau 1394 Posted July 20, 2022 10 hours ago, limelect said: @Remy Lebeau I am with D10.2.3. I run my application on the IDE and see afterward the Indy DCU that before they weren't there so I guess my software uses the compiled INDY. (on the source Delphi directory). I did not remove INDY but I am sure I compiled with INDY DCU I made. Indy comes pre-installed in the IDE. If you want to use your own compiled version of Indy, you should remove the pre-installed one to avoid conflicts. Share this post Link to post
limelect 48 Posted July 26, 2022 @Remy Lebeau well I decided not to do any alteration to Delphi and thanks again Share this post Link to post