Lots of interesting profilers in [WayBack] Profiler and Memory Analysis Tools for Delphi – Stack Overflow:
- Non-unicode Delphi
- Unicode Delphi
--jeroen
Posted by jpluimers on 2021/07/27
Lots of interesting profilers in [WayBack] Profiler and Memory Analysis Tools for Delphi – Stack Overflow:
--jeroen
Posted in Delphi, Development, Software Development | 2 Comments »
Posted by jpluimers on 2021/07/22
Some highlights from [WayBack] console – When is System.IsConsole true in Delphi? – Stack Overflow:
Project/Options/Linking/Generate console application and {$APPTYPE CONSOLE} are two separate things. – [WayBack] Andreas Rejbrand.-cc commandline parameter for dcc32.exe (which could be in your ProjectX.cfg file!) is equivalent to “Generate console application):Found it: the executable has been created using
dcc32.exeand thedpr/cfgfile, thecfgcontains a line-cc
The linker option “Project/Options/Linking/Generate console application” is the same as “DCC_ConsoleTarget” in the .dproj file:
<PropertyGroup Condition="'$(Base_Win32)'!=''"> <DCC_ConsoleTarget>true</DCC_ConsoleTarget> </PropertyGroup>
Even setting IsConsole to True does not allocate a new console, so the STD_OUTPUT_HANDLE handle does not work!
The below method in the System unit, then does not show output:
procedure WriteErrorMessage; {$IFDEF MSWINDOWS} var Dummy: Cardinal; begin if IsConsole then begin with TTextRec(Output) do begin if (Mode = fmOutput) and (BufPos > 0) then TTextIOFunc(InOutFunc)(TTextRec(Output)); // flush out text buffer end; // Leave #0 off end of runErrMsg WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), @runErrMsg, Sizeof(runErrMsg) - 1, Dummy, nil); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), @sLineBreak[1], 2, Dummy, nil); end else if not NoErrMsg then MessageBoxA(0, runErrMsg, errCaption, 0); end;
For console output, you have to enable the linker option DCC_ConsoleTarget allocates a console (if not yet allocated), enables the “STD_OUTPUT_HANDLE” handle, and sets IsConsole to True.
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/21
Below, for my link archive, some searches and relevant posts on FastMM related method calls to track or report memory usage.
Searches:
Posts (note that not all of them get their calculations right):
I have tracked this down to be a version mismatch of the support library
FastMM_FullDebugMode.dll.An older version of the library works with the newer version compiled into the executable. There seems to be no check that versions do match. However, modules don’t really work together at run-time.
- use non-FastMM tools: AQTime, MemProof, SleuthQA
- use FastMM methods GetMemoryManagerSTate, GetMemoryManagerUsageSummary, LogMemoryStateToFile
FastMM4991 introduced a new method,
LogMemoryManagerStateToFile:Added the LogMemoryManagerStateToFile call. This call logs a summary of the memory manager state to file: The total allocated memory, overhead, efficiency, and a breakdown of allocated memory by class and string type. This call may be useful to catch objects that do not necessarily leak, but do linger longer than they should.
These help you track leaks that do not appear as leaks during shutdown: memory allocations that will be released at the end of your application, but are mostly unused while your application is still alive.
A few things to take away from these:
EOutOfMemor) could mean that the memory manager structures are hosed, but memory is still available.A gist with a MemoryManagerUnit showing a few of these calls is below.
An example of its usage is this:
procedure TMyTestClass.TestMethod(); begin TLogMemoryStatesHelper.DumpMemoryStatesBeforeAndAfter('TestMethod', TLogging.LogDir, TFileLogger.GetLogFileName, procedure (const AFormat: string; const Args: array of const) begin TLogging.LogEvent(ltInfoHigh, aFormat, Args); end, procedure() begin try // Given BuildSomeTestScenario(); // When InitializeTestScenario(); // Then CheckEquals(0, TestScenarioSummary()); finally // Cleanup CleanUpTestScenario(); end; end ); end;
–jeroen
Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/20
[WayBack] delphi – How can I enable the memory leak tracking with FastMM in DUnit? – Stack Overflow answered by [WayBack] The_Fox:
You have to build your DUnit GUI-testrunner with the FASTMM and ManualLeakReportingControl directive. This will enable the memoryleak items (Take a look in GUITestRunner.pas).
DUnit with advanced test integrity and memory leak detection
–jeroen
Posted in Conference Topics, Conferences, Delphi, Development, DUnit, Event, FastMM, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/15
Officially, the answer to [WayBack] inheritance – Delphi: How to call inherited inherited ancestor? – Stack Overflow is that you can’t on the language level as I explained in my answer
You can’t in a regular language way, as this would break the object oriented aspects of the language.
You can fiddle around with pointers and clever casts to do this, but before even starting to answer that: is this really what you want?
As others mentioned: your need sounds like a serious “design smell” (which is similar to code smell, but more severe.
Edit:
Going down the pointer fiddling road might save you work in the short term, and cost you weeks of work in the long term.
This makes for some good reading on that: Upstream decisions, downstream costs.
If you really want, then there is a clever hack around this by [WayBack] User kludg – Stack Overflow.
His hack is centered around understanding what what the [WayBack] System.TMethod Record essentially is:
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/14
For my link archive:
Timed Task.
Timed task nameYou create a reference like this:
TimedTask := Parallel.TimedTask.Execute( procedure(const task: IOmniTask) begin // ... end);
In the background, Parallel.TimedTask calls TOmniTimedTask.Create() which calls CreateTask(TOmniTimedTaskWorker.Create(), 'Timed task').Unobserved.Run
The problem is that TOmniTimedTaskWorker is private to the OtlParallel unit, which means you cannot take that call out without also copying that class.
There might be a workaround which I need to research based on the Apply method of IOmniTaskConfig, maybe through Parallel.ApplyConfig. These links might help:
–jeroen
Posted in Delphi, Development, Multi-Threading / Concurrency, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/13
For my link archive:
–jeroen
Posted in .NET, Delphi, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/13
If you get errors loading BPLs that indicate this method cannot be found: “@System@Net@Httpclient@Win@TCertificateStore@$bcctr$qqrv” then it is likely you run Delphi 10.2.2.
Upgrade to Delphi 10.2.3 to resolve this problem.
This happens for instance with binary versions of these below libraries.
They cannot help, as Embarcadero removed the TCertificateStore class (present in Delphi 10.1.2) in 10.2.0, then re-added it in 10.2.3.
Libraries that I bumped into that were affected:
Note that some reports talk about “@System@Net@Httpclient@Win@TCertificateStore@$bcdtr$qqrv” in stead of “@System@Net@Httpclient@Win@TCertificateStore@$bcctr$qqrv“. I am not sure what causes this discrepancy yet.
–jeroen
Posted in Delphi, Delphi 10.2 Tokyo (Godzilla), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/08
For my link archive:
–jeroen
Posted in Database Development, Delphi, Development, Firebird, Software Development | Leave a Comment »
Posted by jpluimers on 2021/07/08
On my research list I have seen this happen with various libraries, but only libraries that deliver a single set of .bpl/.dcp files that you require for both debug and release builds.
The error occurs both ways:
This is with all separate DCU output directories for any permutation in any project: .\$(Platform)\$(Config)\$(SanitizedProjectName)
Example (where xxxx.pas is the first unit depending on Qrctrls, but I have seen it with other libraries that provide .bpl/.dcp combinations as well):
[dcc32 Fatal Error] xxxx.pas(14): E2213 Bad packaged unit format: ..\3rdParty\Quickrep506\19.0\Lib\Win32\Release\QR506RunDXE10_2.dcp.Qrctrls - Expected version: 32.0, Windows Unicode(x86) Found version: 105.101, Unk(CIL)
My best guess is that something is being cached in between builds, but not marked for the correct build configuration well enough.
–jeroen
Posted in Delphi, Delphi 10.2 Tokyo (Godzilla), Development, Software Development | Leave a Comment »