This is a bug in recent versions of Delphi. I just tested it in this latest free Delphi 10.1 Starter, and it behaves the way you described, but since it does not provide RTL sources, I cannot verify the exact cause.
In Delphi XE2, it behaves as expected: it creates a dialog box with the specified model and expects a reaction from you, as described by Sertak.
In Delphi 10.1, a leak is actually reported to the console window, but the program does not stop to wait for the user's attention. This is a bad decision, both for this reason and for the possible use of console programs in scripts (CMD or PS scripts will not "understand" this message and may confuse it with a legitimate exit and fail to complete additional program steps.
I think you need to open a regression type error report over Delphi 10.0, but I donβt think they will fix it before release 10.2.
I also switched your application from the Delphi memory manager to the original one, and then the erroneous behavior was canceled: the program displayed a message box and waited until I let it go before leaving the IDE.
Currently, I suggest you use the mentioned original memory manager, and not its Delphi plug.
program Project1; {$APPTYPE CONSOLE} uses FastMM4, System.Classes, System.SysUtils; ...
The original memory manager is located at http://github.com/pleriche/FastMM4. You can use the Git client in your Delphi or standalone to update it, or you can download the code once and stop updating to you.
Relevant quotes of his code:
{$ifdef LogErrorsToFile} {Set the message footer} LMsgPtr := AppendStringToBuffer(LeakMessageFooter, LMsgPtr, Length(LeakMessageFooter)); {Append the message to the memory errors file} AppendEventLog(@LLeakMessage[0], UIntPtr(LMsgPtr) - UIntPtr(@LLeakMessage[1])); {$else} {Set the message footer} AppendStringToBuffer(LeakMessageFooter, LMsgPtr, Length(LeakMessageFooter)); {$endif} {$ifdef UseOutputDebugString} OutputDebugStringA(LLeakMessage); {$endif} {$ifndef NoMessageBoxes} {Show the message} AppendStringToModuleName(LeakMessageTitle, LMessageTitleBuffer); ShowMessageBox(LLeakMessage, LMessageTitleBuffer); {$endif} end; end; {$endif} end;
and
{Shows a message box if the program is not showing one already.} procedure ShowMessageBox(AText, ACaption: PAnsiChar); begin if (not ShowingMessageBox) and (not SuppressMessageBoxes) then begin ShowingMessageBox := True; MessageBoxA(0, AText, ACaption, MB_OK or MB_ICONERROR or MB_TASKMODAL or MB_DEFAULT_DESKTOP_ONLY); ShowingMessageBox := False; end; end;
This code depends on running on desktop Windows, so perhaps Embarcadero tried to βfixβ it to make it cross-platform. However, as they did, it broke it on the Windows console ....
Also consider using other forms of logging β to a file and / or to Windows debugging lines. They will not be as attractive as a modal window, but at least they will help you save information if you know where to look for it.