- This topic has 11 replies, 3 voices, and was last updated 1 year, 3 months ago by SzakiLaci.
-
AuthorPosts
-
July 25, 2023 at 11:41 pm #71284SzakiLaciParticipant
Please help me, because I’m going crazy and loosing my customer’s trust day by day because of this strange error. 🙁
It appeared since ca 2-3 weeks ago, everything worked fine for years before that.
And I did not change any setup or components since min. 2 years, the only difference is that my program is starting 5 different background threads instead of 4.
(But that thread has nothing to do with AC, only using TUIBDatabase SQL and OverbyteIcs https components, and a thread safe memory-logging system, which also has nothing to do with AC, because none of those are interacting directly with any desktop items.)If I search for this error on this forum, I can find 5 other mentioning about similar topics, but those were very early versions.
The Error:
– Appears after using the program several hours long, so I can not reproduce it on my developer PC.
– Appears both on win7 and Win10
– both on 32 bit / 64 bit. (my exe is always 32bit)
– with different VGA cards and drivers too
– Appears on different forms and actions randomly (will copy more reports to show). But mostly if Form.Show happens.
– it is impossible to continue the program, it is stuck in a loop, no try-except can handle it properly.
– the user can only force-close and restart the whole EXE, while loosing data not yet saved.Attachments:
You must be logged in to view attached files.July 26, 2023 at 12:07 am #71287SzakiLaciParticipantI have a suspicion that this error has to do with Thread safety somehow.
The “new” background thread I mentioned gives “out of memory” messages too, while the program’s mem-usage is under 150MB, and the OS has min. 1GB+ free RAM.
(As You can see from attached bugreports. That thread is called: “HatterNTAK_szal”)I see that from my own LOGs:
When a TUIBQuery component tries to load max 64 tiny rows from database. (Which is very small amount of data, max 1-2 Kbytes.) It can open that table, so the try..except writes: “out of memory” error to my LOG file.
Maybe it has nothing to do with it, but that’s my only “similar error” starting point so far.Also checked the VGA-memory usage, no problems there either.
Worth to mention that I’m using FastMM4 latest module, so that should be stable too.
( Of course with {$define AssumeMultiThreaded} enabled )- This reply was modified 1 year, 4 months ago by SzakiLaci.
July 26, 2023 at 12:33 am #71289SzakiLaciParticipantSorry, forgot to tell: I’m using 2019.05 version: v14.29
object sSkinManager1: TsSkinManager SkinsFilter = [sfiInternal] Effects.AllowAnimation = False AnimEffects.DialogShow.Active = False AnimEffects.FormShow.Active = False AnimEffects.FormHide.Active = False AnimEffects.DialogHide.Active = False AnimEffects.Minimizing.Active = False AnimEffects.PageChange.Active = False AnimEffects.SkinChanging.Active = False AnimEffects.SkinChanging.Time = 0 AnimEffects.SkinChanging.Mode = atDropDown ButtonsOptions.OldGlyphsMode = True ButtonsOptions.ModalButtonsColoring = [] Active = False CommonSections.Strings = ( '[PN_ATLATSZO]' 'TRANSPARENCY=100' '' ... UseCache = False Bitmap = {}
object sSkinProvider1: TsSkinProvider AllowAnimation = False AllowBlendOnMoving = False AllowSkin3rdParty = False ScreenSnap = True AllowExtBorders = False UseGlobalColor = False AddedTitle.Font.Charset = EASTEUROPE_CHARSET AddedTitle.Font.Color = clNone AddedTitle.Font.Height = -11 AddedTitle.Font.Name = 'Arial' AddedTitle.Font.Style = [] SkinData.SkinSection = 'FORM' ...
I guess first thing You will recommend to upgrade it, but I’m afraid something similar may happen, as last time. (Worked several month long to correct all the anomalies.)
July 27, 2023 at 8:15 am #71292LasseParticipantI recommend asking ChatGPT e.g. “How to track GDIError (EOutOfResources = out of memory) errors in Delphi?”. It gives an excellent answer.
I bet my money on creating GDI objects and not deleting them somewhere. I have seen that thousand times.
July 27, 2023 at 8:24 am #71293LasseParticipantThat said… for example find “CreatePen” from AlphaSkins source and you will find a leak in sGraphUtils.pas:
SelectObject(DC, CreatePen(PS_SOLID, 2, clWhite));
That will create a pen and it is never deleted. The code should be like:
var LPen: HPEN; begin LPen := CreatePen(...); try // Use the pen for drawing finally DeleteObject(LPen); // Release the GDI pen object end; end;
- This reply was modified 1 year, 4 months ago by Lasse.
July 27, 2023 at 9:45 am #71297SzakiLaciParticipantThank you very much!
I will change that.Can You please add a few more examples, what else to search for, not just “CreatePen” ?
And yes, I’ve also noticed there are still some memory leaks in the code.
But it seems it has improved a lot since the 2019 version.
noticed Serge forgets to put:
inherited Destroy;
to the end of the Destroy procedures after all other “clearings”, instead of the beginning.2.
Do you know if it’s enough toFreeAndNil(FTextTimer)
a timer component, instead of first stopping it by :
FTextTimer.Enabled := False;
?
(like he does at:destructor TacCustomCombo.Destroy;
)July 28, 2023 at 6:01 am #71301LasseParticipantYou can check what objects can be created for SelectObject.
– Bitmap: CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap, CreateDIBitmap, CreateDIBSection
– Brush: CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt, CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
– Font: CreateFont, CreateFontIndirect
– Pen: CreatePen, CreatePenIndirect
– Region: CombineRgn, CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn, CreateRectRgn, CreateRectRgnIndirectI have mostly seen CreatePen and CreateBrush leaks. But there are also many other kind of traps to fall into. The worst I know is SHGetFileInfo where you need to destroy the icon handle, if you are not using it. Usually you’re only interested in icon index.
For example
function GetIconIndex(const AFilename: string; const AFileAttributes: Cardinal; const AMoreFlags: Cardinal): Integer; var LFileInfo: TSHFileInfo; begin if SHGetFileInfo(PChar(AFilename), AFileAttributes, LFileInfo, SizeOf(TSHFileInfo), SHGFI_SYSICONINDEX or SHGFI_SMALLICON or SHGFI_ICON or AMoreFlags) = 0 then Result := -1 else begin Result := LFileInfo.iIcon; { Important! Destroy the icon, we are only using the index. } DestroyIcon(LFileInfo.hIcon); end; end;
July 28, 2023 at 6:03 am #71302LasseParticipantYes, FreeAndNil(FTextTimer) is ok.
TTimer destroy will disable it.
destructor TTimer.Destroy; begin FEnabled := False; ...
July 31, 2023 at 7:38 pm #71305SzakiLaciParticipantAfter I’ve upgraded to latest version=17.01
this error seems to disappeared. (But not tested enough yet… so it’s not final.)But, other huge errors started to appear, like:
sendtoback-brings-the-form-to-foregroundAugust 3, 2023 at 11:25 am #71307August 3, 2023 at 3:08 pm #71310SzakiLaciParticipantDear Chris2023,
Please delete your post.
This is not a solution.August 9, 2023 at 8:00 am #71316SzakiLaciParticipantAfter I’ve upgraded to latest version=17.01
this error seems to disappeared. (But not tested enough yet… so it’s not final.)I take it back 🙁
It has turned out: the same error can still happen with the latest version too.
While it’s rare compared to the old one.So I will put back the 2019 version, it was much much more stable and will enhance the AC code with the recommended try…finally and some try..except lines.
-
AuthorPosts
- You must be logged in to reply to this topic.