- This topic has 7 replies, 2 voices, and was last updated 6 years, 1 month ago by HeDiBo.
-
AuthorPosts
-
August 26, 2018 at 4:17 pm #37921HeDiBoParticipant
In the acgpUtils.pas there is this piece of code in the procedure acgpBlur:
Code:acGdipBitmapCreateApplyEffect(@NativeInputs[0], 1, NativeHandle, @R, @R, OutBitmap, False, OutAux, OutAuxSize);
acGdipCreateHBITMAPFromBitmap(OutBitmap, OutBmp, 0); // <<< This causes a memory leak.
Bmp.Handle := OutBmp;
end;
finally
acGDIEnd(IsLibrary);
end;Just calling GdiplusShutdown (acGDIEnd) is not enough to free resources. This is from the Microsoft docs on GDI+:
“You must call GdiplusStartup before you create any GDI+ objects, and you must delete all of your GDI+ objects (or have them go out of scope) before you call GdiplusShutdown.”
So, this creates a memory leak.
Another memory leak occurs because of this piece of code in TsSplitView.UpdateBGBmp:
Code:if BGBmp = nil then
BGBmp := CreateBmp32(Size)
else begin
BGBmp.Width := Size.cx;
BGBmp.Height := Size.cy;
end;Apparently BGBmp is not freed in my project. I think this should probably be done with a global list of BGBmp's that is freed in the Finalization section.
This memory leak occurs in a number of places.
Here is the memory leak log:
[attachment=8870:WIP4_MemoryManager_EventLog.txt]
August 27, 2018 at 5:01 pm #58311SupportKeymasterHello and thank you for researching.
I will check and fix it.
August 28, 2018 at 12:19 pm #58313HeDiBoParticipant'Support' wrote:Hello and thank you for researching.
I will check and fix it.
I found that removing the memory leak from TsSplitView, removes the other ones too.
This change did it:
Code:destructor TsSplitView.Destroy;
begin
FBlurData.Free;
FreeAndNil(BGBmp); (*** DB ***)
FreeAndNil(BluredBmp); (*** DB ***)
inherited;
end;September 4, 2018 at 3:05 pm #58323SupportKeymasterHello and thank you for the information.
I have checked GDI Plus functions, GdiplusStartup is called there in the acGDIBegin procedure.
Memory leak will be removed very soon I think, some problems with reproduction of the problem exists.
September 4, 2018 at 3:19 pm #58315HeDiBoParticipant'Support' wrote:Hello and thank you for the information.
I have checked GDI Plus functions, GdiplusStartup is called there in the acGDIBegin procedure.
Memory leak will be removed very soon I think, some problems with reproduction of the problem exists.
The problem is only in TsSplitView, as mentioned above. Freeing the bitmaps mentioned will solve the memory leak.
September 4, 2018 at 3:23 pm #58316SupportKeymasterYes, this code should work, but it will be great if I can find a reason of this leak.
September 4, 2018 at 3:27 pm #58317HeDiBoParticipant'Support' wrote:Yes, this code should work, but it will be great if I can find a reason of this leak.
In sPanel the allocation of BGBmp especially is a bit fishy. It is very hard to find why it is freed if the application is stopped when the bitmap is allocated.
September 19, 2018 at 11:15 am #58390HeDiBoParticipantSolved.
(You didn't need to keep my initials in the bug fix, but I appreciate it.)
-
AuthorPosts
- You must be logged in to reply to this topic.