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
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
I fixed it (as a workaround) including ShareMem as first unit in uses in my project source.
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}
Related
I currently have a problem loading/unloading the avfilter-7.dll from ffmpeg 4.22 (x86)
using Delphi 2007 (also with Delphi XE3..same problem)
Each loading / unloading process of the library causes a handles leak
in Windows x64 Pro for which I currently have no explanation or solution.
I have already tried to upgrade to a newer version of the DLL but the leak is even worse,
strangely, a very old version (avfilter-2.dll) is not affected by this
dllLHandle := LoadLibrary(PAnsiChar('c:\Windows\SysWow64\AVFilter-7.dll'));
if dllLHandle<>0 then begin
FreeLibrary(dllLHandle);
dllLHandle:= 0;
end;
The code above causes an additional leak with each call
Is there something wrong, have I forgotten something?
I have a really old (Photoshop SDK for Delphi from Centaurix Interactive) component set. We could recompile it and successfully use it in our application without any problem. But it has started to create an access violation when we upgrade to Delphi 11.
If I change the line for memory allocation from
new(Stub) to Stub:= VirtualAlloc(nil, SizeOf(TStub), MEM_COMMIT, PAGE_EXECUTE_READWRITE)
it works at first, but it creates several 'memory problems' during further operations...
what's the reason for this issue, and is there any compiler directive or workaround to fix this?
Update : It is a Windows 32bit application and it could work with delphi 10.3 so it supports unicode.
I found the reason for this issue. it is not directly creating memory allocation but about creating a stub function for dll. Several PE security flags have been introduced in Delphi 11. you can find the details in Marco Cantu's blog.
One of them, DEP flag, apparently prevents some memory operations. If I uncheck it, the application works pretty well.
On my project, I am using inherited MDIChild forms from base form. My problem is about memory management. After release forms ( by FreeAndNil) with FormClose events, Delphi still keep on memory and do not release.
What should I do for that? MDI management different or what?
I doubt it has something to deal with the children Forms, even when you terminate an application with several children forms open Delphi will free them without memory leaks.
To get a hint of what's going on, at your Source Project's code insert this,
Begin
ReportMemoryLeaksOnShutdown:= DebugHook <> 0;
…
end.
Run the application in the IDE, do something you usually do then close the application. Delphi will inform you the memory leaks it encounters and a hint of what it is.
I always use above line in my applications, when testing (debugging), Delphi informs about memory leaks on shutdown.
I use FastMM4, normally in full debug mode during development. If I turn off this mode should I arrange my app to go back to the Delphi (XE2) MM or is there a performance benefit in leaving FastMM4 linked all the time?
Delphi's memory manager (since D2007, IIRC D2006) is FastMM4, so you won't get any improvement in speed. The full FastMM4 might be faster, because you get improvements and bug fixes by using it straight from the source.
I'm sitting with an OpenGL 3.2 application in Delphi 2009. When using FastMM 4.97 with FullDebugMode defined the UBOs does not get their data properly. With FullDebugMode undefined everything works like a charm.
Example:
Setting the viewport dimensions pointing to two private integer fields, FWidth and FHeight, in our render frame class.
glBufferSubData(GL_UNIFORM_BUFFER, VUniform.Offset, VUniform.Size, #FWidth);
I've been pulling my hair over this issue for a few days now and I really don't know how to proceed. I'm not expecting full OpenGL support here but hopefully someone can come with some suggestion based on known differences between running in FullDebugMode and not.
Project settings:
[Compiling]
Optimization False
Stack frames True
Use debug .dcus True
[Linking]
Debug info True
Map file Detailed
OS is Windows 7 64 bit.
Edit:
Found it!
It had nothing at all to do with OpenGL. Elsewhere in our codebase a function returned a PAnsiChar using Result := #AnsiString(Object.Name)[1]; This worked most of the time running normally since the memory was only released but unchanged. In FullDebugMode the data was overwritten with $80 sequence when freed.
You are probably looking at memory that has been freed prematurely (by your own application).
Normally, you'd still be able to access the old values until they are overwritten by a new allocation + writes. This could very well allow your application to run properly, even though you are accessing stale (freed) parts of memory.
However, in FullDebugMode, deallocated memory is filled with a byte $80 sequence. You can easily check for this if you know the exact call to glBufferSubData that breaks, simply take a look at the memory at that point.