You are not logged in.
Pages: 1
Hi everyone.
Madexcept report memory leak in this function:
I attached source and image of madexceptt report:
source:
https://gist.github.com/a-nouri/65937e5 … 248db87090
madexcept memory leak report:
https://passak.org/mormot/Untitled.png
Last edited by anouri (2025-11-19 11:18:51)
Offline
I don't see any match between the source and the leak report.
What is leaked? A class? A string?
From the stack trace, it sounds like if the allocation was done in MadExcept exception interceptor itself.
Do you use both MadExcept and TSynLog exception interception at the same time?
Use FastMM4 in full debug mode instead.
It sounds like a more reliable option.
Offline
Yes I used both madexcept and tsynlog.
I set global synlog setting:
var
LogFamily: TSynLogFamily;
....
LogFamily := SQLite3Log.Family;
LogFamily.Level := LOG_VERBOSE;
LogFamily.PerThreadLog := ptIdentifiedInOnFile;
but my rest server is restserverfullmemory.
without madexcept or urokalog how can I find memory leaks?
Last edited by anouri (2025-11-19 13:55:22)
Offline
without madexcept or urokalog how can I find memory leaks?
If you're using the default Memory Manager (FastMM) then you can also just use the Delphi method.
Put this in the .dpr below the Application.Initialize line.
{$WARN SYMBOL_PLATFORM OFF}
ReportMemoryLeaksOnShutdown := DebugHook <> 0;
{$WARN SYMBOL_PLATFORM ON}https://docwiki.embarcadero.com/Librari … OnShutdown
And now if you run with debugger on (DebugHook > 0) then it will popup a message when closing your app if there is a memory leak.
You can also just set it to true but I like to always have it when I'm running with debugger (not as user).
Offline
Thakns.
Let me find where can I activate full debug mode for fastmm4.
Offline
This is memory leak :
var
P: PByte;
begin
GetMem(P, 10);
fastmm report leak on shutdown:
1-12 bytes: Unknown x 1
how can I find location of memory leak?
madexcept shows line number and unit name. what about fastmm
Offline
how can I find location of memory leak?
madexcept shows line number and unit name. what about fastmm
The default fastmm is very basic in Delphi and it doesn't show the line number etc. It just shows the leaked memory. Often you can see what type of record is leaked. But if you can't you will need something stronger.
You could use the full FastMM4 library. It would involve adding a dll to your exe directory and putting 3 files (2 pas and 1 inc) in your source directory. Defining FullDebugMode in the inc and running it with a debugger on, it will provide you with a txt file which shows the location the leaked memory was created.
See for more info: https://stackoverflow.com/a/1130506
This would show something like (from your example, so the GetMem would be on line 8 of test):
--------------------------------2025/11/21 10:46:05--------------------------------
A memory block has been leaked. The size is: 12
This block was allocated by thread 0x4004, and the stack trace (return addresses) at the time was:
4046BE [System.pas][System][System.@GetMem][4749]
42155E [test][test.test][8]
76B1FCC9 [BaseThreadInitThunk]
77DE82AE [RtlGetAppContainerNamedObjectPath]
77DE827E [RtlGetAppContainerNamedObjectPath]
The block is currently used for an object of class: Unknown
The allocation number is: 111
<snip_and_more>Offline
Pages: 1