Terenz Posted February 8, 2017 Posted February 8, 2017 (edited) Hi, most of the code is made by @UEZ. Ignore the "Internal" if you use the last stable, i'm still using the old for compatibility reason with unsopported OS The code work, and is cool! But there is a problem somewhere. If i'll open the task manager i'll see the "working set memory" increase, and increase, and increase...like 500kb every 10 seconds! I don't think is normal Maybe i have forget some *Dispose? I'll see all there. I don't know where is the problem with that code, any hint? Thanks Edited February 23, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
Danyfirex Posted February 9, 2017 Posted February 9, 2017 Hello. I didn't run the code but I think you forgot to dispose $hBackbuffer Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Terenz Posted February 9, 2017 Author Posted February 9, 2017 (edited) Hi @Danyfirex, Yes i have forget the $hBackbuffer, added _GDIPlus_GraphicsDispose to that but it still eat memory in some way. I have added to my code _WinAPI_GetProcessMemoryInfo with [2], the current working set size, in bytes. Result after 30 seconds, more or less START: 10543104 08:16:01: 12197888 08:16:02: 12709888 08:16:03: 12759040 08:16:04: 12763136 08:16:05: 12779520 08:16:06: 12816384 08:16:07: 12730368 08:16:08: 12730368 08:16:09: 12857344 08:16:10: 12861440 08:16:11: 12881920 08:16:12: 12894208 08:16:13: 12894208 08:16:14: 12894208 08:16:15: 12894208 08:16:16: 12894208 08:16:17: 12894208 08:16:18: 12894208 08:16:19: 12894208 08:16:20: 12902400 08:16:21: 12935168 08:16:22: 12935168 08:16:23: 12935168 08:16:24: 12943360 08:16:25: 13078528 08:16:26: 13078528 08:16:27: 13099008 08:16:28: 13099008 08:16:29: 13099008 08:16:30: 13099008 08:16:31: 13099008 08:16:32: 13099008 08:16:33: 13099008 Has you can see it increase from 12197888 to 13099008 Edited February 9, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
UEZ Posted February 9, 2017 Posted February 9, 2017 (edited) That's easy to fix: While 1 $aMsg = GUIGetMsg() If $sSEC <> @SEC Then $sSEC = @SEC $iNUMBER += 1 $hBmpGDI = _GDIPlus_BitmapText("TEST_" & $iNUMBER) _WinAPI_BitmapDisplay($hBmpGDI, $hGUI) $aMem = _WinAPI_GetProcessMemoryInfo(@AutoItPID) ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & ": " & $aMem[2] & @CRLF) _WinAPI_DeleteObject($hBmpGDI) ;dispose the GDI image EndIf WEnd _GDIPlus_BitmapText function returns here a GDI bitmap handle which isn't disposed in your example. $hBmpGDI = _GDIPlus_BitmapText("TEST_" & $iNUMBER) Btw, to get the transparent effect comment out the line _GDIPlus_GraphicsClear($hBackbuffer, "0xFF000000") in function _GDIPlus_BitmapText. Edited February 9, 2017 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Terenz Posted February 9, 2017 Author Posted February 9, 2017 (edited) Hi @UEZ, my favorite GDI+ hero Well in theory i'm disposing the $hBmpGDI in the _WinAPI_BitmapDisplay $hBmpGDI = _GDIPlus_BitmapText("TEST_" & $iNUMBER) _WinAPI_BitmapDisplay($hBmpGDI, $hGUI) Func _WinAPI_BitmapDisplay(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $bReleaseGDI = True) ;cut If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc ;==>_WinAPI_BitmapDisplayTransparentDigital Also adding _WinAPI_DeleteObject inside the loop i see the memory increasing START: 10526720 09:25:11: 12554240 09:25:12: 12787712 09:25:13: 12800000 09:25:14: 12804096 09:25:15: 12820480 09:25:16: 12857344 09:25:17: 12771328 09:25:18: 12771328 09:25:19: 12902400 09:25:20: 12918784 09:25:21: 12926976 09:25:22: 12939264 09:25:23: 12939264 09:25:24: 12939264 09:25:25: 12939264 09:25:26: 12939264 09:25:27: 12939264 09:25:28: 12939264 09:25:29: 12939264 09:25:30: 12947456 09:25:31: 12980224 09:25:32: 12980224 09:25:33: 12980224 09:25:34: 12988416 09:25:35: 13123584 09:25:36: 13123584 09:25:37: 13144064 12554240 to 13144064 after 26 seconds EDIT: I have check also with the last autoit stable, just for exclude a problem of my version. Is pratically the same increase with different value, from 17772544 to 18325504 after 19 seconds. Comment-out _WinAPI_BitmapDisplay don't resolve the memory increasing, something in the code of _GDIPlus_BitmapText create the issue? Edited February 9, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
UEZ Posted February 9, 2017 Posted February 9, 2017 (edited) You are right @Terenz that _WinAPI_BitmapDisplay() function disposes the returned GDI bitmap handle. Anyhow, if you for example run these lines: While 1 $aMsg = GUIGetMsg() ;~ If $sSEC <> @SEC Then $sSEC = @SEC $iNUMBER += 1 $hBmpGDI = _GDIPlus_BitmapText("TEST_" & @MSEC) _WinAPI_BitmapDisplay($hBmpGDI, $hGUI) $aMem = _WinAPI_GetProcessMemoryInfo(@AutoItPID) ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & ": " & $aMem[2] & @CRLF) ;~ _WinAPI_DeleteObject($hBmpGDI) ;~ EndIf WEnd the memory consumption vary between 12.9 - 13.9 mb (on my system). That's not a memory leak. Probably what Danyfirex mentioned caused the memory leak. Edited February 9, 2017 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Terenz Posted February 9, 2017 Author Posted February 9, 2017 @UEZ I'll really hope "the culprit" was just the one missed GraphicsDispose. But if you and @Danyfirex can confirm the code is good in any aspect without any memory leak, i'll trust. Nothing is so strong as gentleness. Nothing is so gentle as real strength
Danyfirex Posted February 9, 2017 Posted February 9, 2017 Hello. As I said the only issue seems to be what I've told above. I tested with 120.000 loops and it stays between 9.000K-11.000K in my machine. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Terenz Posted February 12, 2017 Author Posted February 12, 2017 (edited) Edit, sorry for the re-up. Just a wrong implementation of the help. Edited February 12, 2017 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now