'TGPUObjectsPool memory leak on shutdown in Delphi 11.1 FMX
Running 11.1, I get this TGPUObjectsPool error on shutting down a simple basic FMX 2D app under Windows 64-bit (Release mode). First time I have seen this error.
Just running a blank form with ReportMemoryLeaksOnShutdown := True in project.dpr results in this error on closing.
There are no components on the TForm. Just run and close. It makes me wonder what kind of QA is done for a Delphi release if a basic empty project can close with such memory leaks.
Any solutions to get rid of this error?
---------------------------
Unexpected Memory Leak
---------------------------
An unexpected memory leak has occurred. The unexpected small block leaks are:
9 - 24 bytes: TGPUObjectsPool x 1
89 - 104 bytes: TObjectDictionary<System.TClass,System.Generics.Collections.TObjectList<FMX.TextLayout.GPU.TReusableObject>> x 1
Solution 1:[1]
Try this:
uses
{$IFDEF VER350} // 11.x
FMX.FontGlyphs, FMX.TextLayout.GPU,
{$ENDIF}
finalization
{$IFDEF VER350} // 11.x
// RAD Studio 11 memory leak
TFontGlyphManager.UnInitialize;
TGPUObjectsPool.Uninitialize;
{$ENDIF}
Solution 2:[2]
It makes me wonder what kind of QA is done for a Delphi release
A lot, actually. Months of beta testing, lots of fixes and internal builds.
This issue was actually reported during testing, but only just a couple of weeks ago, after it was too late to fix for the final release. But, this leak (and others) have been reported publicly after 11.1 was released:
RSP-37596 FMX TFontGlyphManager's UnInitialize not called in finalization
RSP-37600 Unexpected Memory Leak in TGPUObjectsPool
RSP-37613 Memory leak in an application that only serves forms
RSP-37656 Memory leak in FMX (simple project)
And there are other similar memory leaks (in TFontGlyphManager, TBehaviorServices, etc), so hopefully this will get fixed in the next update.
I guess maybe they should consider having their samples include the ReportMemoryLeaksOnShutdown=True.
Funny, because I see a similar report for that, too:
RSP-37598 Make RTL, FMX and VCL developers turn on memory leak checking by default
Solution 3:[3]
I fixed it (as a workaround) including ShareMem as first unit in uses in my project source.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | NBuyer |
| Solution 2 | |
| Solution 3 | TwistedNerves |
