chrisser

Memoryleak / AutoIT crash - Loading BMP-Files from Binary

5 posts in this topic

Hi,

i try to load an image from binarydata to my GUI. The problem is, that my AutoIT.exe crashes after some minutes (Exitcode is in the box below). And i think this Script doesn´t release the memory of the picture. The taskmanager-entry is growing and growing. Does someone see my problem?

Thanks Chris

Usede AutoIT Version 3.3.14.2 / 3.3.15.0

Error:

!>14:51:13 AutoIt3.exe ended.rc:-1073741819
+>14:51:13 AutoIt3Wrapper Finished.
>Exit code: 3221225477

Here is an Example (Error all 3-10 minutes)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Memory.au3>
#include <Constants.au3>
#include <APIConstants.au3>
#include <WinAPIEx.au3>
#include <GDIPlus.au3>
Global $pic = "0xFFD8FFE000104A46494600010101006000600000FFDB004300080606070605080707070909080A0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C303134" & _
"34341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D1832211C213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232FFC0" & _
"0011080045006F03012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D010203000411051221314106135" & _
"16107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A434445464748494A535455565758595A636465666768696A737475767778797A838485868788898A92" & _
"939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F010003010101010101010101000000000" & _
"0000102030405060708090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0156272D10A162434E125F11718191A26272829" & _
"2A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD" & _
"2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00F43F0F476371A4DA241A3586C8ADA2DC64857712541EE3DFD6B50D8C276FFC49B4B1C7CDFBA4E3E9C5647851" & _
"99747CA3EC6F220C367FD85ADDDD330E2EB3EDB8FF0085525A5C4EE34585893CE97A6A0EE0C2991FA5595D2F4EC67FB274F39E47EE13FC29D6D2AA902493730E98C9AB5E6AFF00B5FF007C9A2C172AFF0065E9FF0" & _
"0F408B0FF00BF09FE14874DD395493A4586075FDC2FF855EA8E74596DE48DC651D4AB0F5078345905CA89A769D20529A35890C32316E9C8FCA9DFD9563FF404B2FF00BF09FE1459E9D0E9D149158DA98813B87CE4" & _
"F38C7727D2A6265C054C72410339C71CD0D2BE809BB6A51F2B46DFB3FB374EDD9C63C84EBF954E34CB0270345B2CFF00D704FF000AB6824E59D09939C3638A512DC023CC3B41F503FC693B741E854FECAB1FFA025" & _
"97FDF84FF000A3FB2AC7FE80965FF007E13FC2ADA4B741097049C7040039FCE93CE9FCADE3249E70481B690157FB2AC7FE80965FF0080E9FE14A9A569E5C03A2D9007BFD9D3FC2AC3CB73B772B30F98F18078A485" & _
"A49258E4954BB2B1D8781D41CD311CB783235974F457195FB3C271FF00005AE8F33F4B711951D986306B9EF0467EC31FA7D9E2CFFDF0B5D14B03846F2E57F60339CFE1551DAC0C7AFDA304385C9E8CBD054B87FEF" & _
"8FF00BE6A92DC3A12AEED9538CB77FD2AD89E2C03E628CFA9A7664DD10FDA18C8F1AB0DC879E073EFD7F0A7EF9361661F20EA70063F5A85994BEE0D95F6A953849B9E88BFCEA1B2922CBC2F7080661684E0E369E4" & _
"7D73527D993733796996CE793CE6B28118EA78A3B0393EB486688B4DB26E558C00723AFE348C9042E3708D5BA8CB1AA0AC83AE79071569BE49AD413D7FA9A009E211094F97E5EFC73863D29ED29DED1A9432019DA" & _
"0F354E690477BB893C376A74D2C62E564704A119C7E14011C5752C92DC46F6EC3CA048391F376C8AB70B6F287CBDBF363EF67B1AAA0B0BB99A385A42C8C0E0E3BF152DABCA5D55EDD917767248F43403D5E872DE0" & _
"9FF8F24E7A5BC5C7FC016BAB6018608C835CAF823FE3C17FEBDE1FFD016BAAAA4265792D622A4E76F724F354641B5CC6B965EC4569C85C6368E0F538C9150BDBC6F21674959BB91C0356ADD497E4410E5A143B40C" & _
"83C63A73565492B2E17AA2FE1CD401638C2A0C8001C063CF7A7875CB00C3050679AC8B18338238A067A714D52983C8EA7BD2AB217392383C73ED400B8385E9C0AB4EDBE7B5C0EC3F9D55CC617823F3F6A9F72F9F6" & _
"C770E9EBEF4005C296BA20773E99A59223248A819570A012DC76F4A19946A00EE1F7BAE6A47F2DF51504839F7F6A007DB0C5CC83D33FCEACBFDE8FFDEFE86ABDBFFC7DCBF53FCEAC3FDE8FFDEFE868038AF047FC7" & _
"8A7FD7BC5FF00A02D7532063190B9DDDB158BA169B2268B632420C65ED6225978CFC82B4C5ADD6465A5C77C3D52690AC519649A299D55CAE58903763F1A4135C7FCF57EBCFCDDAAFF00D81C60EE9CF73C83CD3D6C" & _
"64CE0493A81FED0A7A770B1523FB2C8ECF2A1DC3B9CE0FEA6A422C08E1579E9C1A9CD84BCE1E6E4FF7874A4FECF97FE7A4BF98A7602A95B36DD911124F07CB3C500DB05FF96617B7EE6AF8B5942E324FFC0579A3E" & _
"CD371C9C63A6D5A561953C9B494A868A3DC471F7973F91A5FECFB43D228FF00EFE37F8D5F4B423EFC99FA2014F16883A311F403FC2A5D80CEFECEB6FF009E09FF007DBFF8D28D3EDD4E442A0FB3BFF8D687D9C7FC" & _
"F46FD28FB38FF9E8DFA51A08A91DBAC4DB91707FEBA39FEB53442537419A4CA76403A7152FD9C7FCF46FD283088C6EDEE71DB028BA03E75B0F89BE224B3B3847D88A8B389D7F7072382B8FBDFEC8AB6DF157C431C" & _
"59F234D6C7ADBB73FF8F51452190FFC2DEF117FCFAE97FF007E1BFF008AA2CBE2DF892F35BB5B13069691CD288CB0B66247CB9CFDFA28A4F613D8AE3E317898D899FECFA56E168D718FB3363224D98FBFD31525CF" & _
"C5EF12C17AF6E21D2C859D22CFD99BA326ECFDFEB451551D69DFCFFCC5276A96FEBA0ABF173C4C74E86EBC9D2B749652DCEDFB2B601490A01F7FA1C66A78BE2AF8924BA68BCBD3005BAB6833F666CE255249FBFD4" & _
"628A29C9593F4FD0E8515CB4FCDBFCCA56FF18BC4D34F731B5BE9404514B2022D9B928703F8EA3D5BE34789AC2F04315AE9254A06F9ADDB3CFF00C0E8A2A56C67256651FF0085EBE2AFF9F3D1FF00F019FF00F8BA" & _
"D1B6F8C7E279AD44C6DF4A049C605B37FF00174514D0A3ABFBFF0026599BE2D789A0B759D63D2F27903ECADC700FF7E9F71F193C5B06E651A59DAB1B0DD6ADFC48A4FF001FFB545143262F43FFD9"

$timer = TimerInit()
Dim $DemoPicture[10]
    Local $hGUI = GUICreate("Example",1200)
      For $i = 1 To 9
        $DemoPicture[$i] = GUICtrlCreatePic("",10+120,10 ,111,69)
      Next
    GUISetState(@SW_SHOW, $hGUI)
    While 1
        If TimerDiff($timer) > 1 Then
            _Set_PreviewPic()
            $timer = TimerInit()
        EndIf

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
            Exit
        EndSwitch
    WEnd


;===================================================================================================
Func _Set_PreviewPic()
      For $i = 1 to 9
        Global $Bmp_Logo = Load_BMP_From_Mem(Binary($pic), True)
        _WinAPI_DeleteObject(GUICtrlSendMsg($DemoPicture[$i -1], 0x0172, 0, $Bmp_Logo))
        _WinAPI_DeleteObject($Bmp_Logo)
    Next
EndFunc


;======================================================================================
; Function Name:        Load_BMP_From_Mem
; Description:          Loads a image which is saved as a binary string and converts it to a bitmap or hbitmap
;
; Parameters:           $mem_image:     the binary string which contains any valid image which is supported by GDI+
; Optional:                 $hHBITMAP:      if false a bitmap will be created, if true a hbitmap will be created
;
; Remark:                   hbitmap format is used generally for GUI internal images
;
; Requirement(s):       GDIPlus.au3, Memory.au3
; Return Value(s):  Success: handle to bitmap or hbitmap, Error: 0
; Error codes:          1: $mem_image is not a binary string
;
; Author(s):                UEZ
; Additional Code:  thanks to progandy for the MemGlobalAlloc and tVARIANT lines
; Version:                  v0.95 Build 2011-06-11 Beta
;=======================================================================================

Func Load_BMP_From_Mem($mem_image, $hHBITMAP = False)
    If Not IsBinary($mem_image) Then Return SetError(1, 0, 0)
    Local $declared = True
    If Not $__g_hGDIPDll Then
        _GDIPlus_Startup()
        $declared = False
    EndIf
    Local Const $memBitmap = Binary($mem_image) ;load image  saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory  ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count  associated with a memory object that was allocated with GMEM_MOVEABLE
    Local $hStream = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0)
    $hStream = $hStream[3]
    Local $hBitmap = DllCall($__g_hGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    $hBitmap = $hBitmap[2]
    Local Const $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
                                           "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    If $hHBITMAP Then
        Local Const $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        If Not $declared Then _GDIPlus_Shutdown()
        Return $hHBmp
    EndIf
    If Not $declared Then _GDIPlus_Shutdown()
    Return $hBitmap
EndFunc   ;==>Load_BMP_From_Mem

 

Share this post


Link to post
Share on other sites



You are allocating memory (_memGlobalAlloc), but never releasing it (_MemGlobalFree).

Share this post


Link to post
Share on other sites

Load_BMP_From_Mem is obsolete, use _GDIPlus_BitmapCreateFromMemory instead:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Memory.au3>
#include <Constants.au3>
#include <APIConstants.au3>
#include <WinAPIEx.au3>
#include <GDIPlus.au3>

Global $pic = "0xFFD8FFE000104A46494600010101006000600000FFDB004300080606070605080707070909080A0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C303134" & _
"34341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D1832211C213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232FFC0" & _
"0011080045006F03012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D010203000411051221314106135" & _
"16107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A434445464748494A535455565758595A636465666768696A737475767778797A838485868788898A92" & _
"939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F010003010101010101010101000000000" & _
"0000102030405060708090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0156272D10A162434E125F11718191A26272829" & _
"2A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD" & _
"2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00F43F0F476371A4DA241A3586C8ADA2DC64857712541EE3DFD6B50D8C276FFC49B4B1C7CDFBA4E3E9C5647851" & _
"99747CA3EC6F220C367FD85ADDDD330E2EB3EDB8FF0085525A5C4EE34585893CE97A6A0EE0C2991FA5595D2F4EC67FB274F39E47EE13FC29D6D2AA902493730E98C9AB5E6AFF00B5FF007C9A2C172AFF0065E9FF0" & _
"0F408B0FF00BF09FE14874DD395493A4586075FDC2FF855EA8E74596DE48DC651D4AB0F5078345905CA89A769D20529A35890C32316E9C8FCA9DFD9563FF404B2FF00BF09FE1459E9D0E9D149158DA98813B87CE4" & _
"F38C7727D2A6265C054C72410339C71CD0D2BE809BB6A51F2B46DFB3FB374EDD9C63C84EBF954E34CB0270345B2CFF00D704FF000AB6824E59D09939C3638A512DC023CC3B41F503FC693B741E854FECAB1FFA025" & _
"97FDF84FF000A3FB2AC7FE80965FF007E13FC2ADA4B741097049C7040039FCE93CE9FCADE3249E70481B690157FB2AC7FE80965FF0080E9FE14A9A569E5C03A2D9007BFD9D3FC2AC3CB73B772B30F98F18078A485" & _
"A49258E4954BB2B1D8781D41CD311CB783235974F457195FB3C271FF00005AE8F33F4B711951D986306B9EF0467EC31FA7D9E2CFFDF0B5D14B03846F2E57F60339CFE1551DAC0C7AFDA304385C9E8CBD054B87FEF" & _
"8FF00BE6A92DC3A12AEED9538CB77FD2AD89E2C03E628CFA9A7664DD10FDA18C8F1AB0DC879E073EFD7F0A7EF9361661F20EA70063F5A85994BEE0D95F6A953849B9E88BFCEA1B2922CBC2F7080661684E0E369E4" & _
"7D73527D993733796996CE793CE6B28118EA78A3B0393EB486688B4DB26E558C00723AFE348C9042E3708D5BA8CB1AA0AC83AE79071569BE49AD413D7FA9A009E211094F97E5EFC73863D29ED29DED1A9432019DA" & _
"0F354E690477BB893C376A74D2C62E564704A119C7E14011C5752C92DC46F6EC3CA048391F376C8AB70B6F287CBDBF363EF67B1AAA0B0BB99A385A42C8C0E0E3BF152DABCA5D55EDD917767248F43403D5E872DE0" & _
"9FF8F24E7A5BC5C7FC016BAB6018608C835CAF823FE3C17FEBDE1FFD016BAAAA4265792D622A4E76F724F354641B5CC6B965EC4569C85C6368E0F538C9150BDBC6F21674959BB91C0356ADD497E4410E5A143B40C" & _
"83C63A73565492B2E17AA2FE1CD401638C2A0C8001C063CF7A7875CB00C3050679AC8B18338238A067A714D52983C8EA7BD2AB217392383C73ED400B8385E9C0AB4EDBE7B5C0EC3F9D55CC617823F3F6A9F72F9F6" & _
"C770E9EBEF4005C296BA20773E99A59223248A819570A012DC76F4A19946A00EE1F7BAE6A47F2DF51504839F7F6A007DB0C5CC83D33FCEACBFDE8FFDEFE86ABDBFFC7DCBF53FCEAC3FDE8FFDEFE868038AF047FC7" & _
"8A7FD7BC5FF00A02D7532063190B9DDDB158BA169B2268B632420C65ED6225978CFC82B4C5ADD6465A5C77C3D52690AC519649A299D55CAE58903763F1A4135C7FCF57EBCFCDDAAFF00D81C60EE9CF73C83CD3D6C" & _
"64CE0493A81FED0A7A770B1523FB2C8ECF2A1DC3B9CE0FEA6A422C08E1579E9C1A9CD84BCE1E6E4FF7874A4FECF97FE7A4BF98A7602A95B36DD911124F07CB3C500DB05FF96617B7EE6AF8B5942E324FFC0579A3E" & _
"CD371C9C63A6D5A561953C9B494A868A3DC471F7973F91A5FECFB43D228FF00EFE37F8D5F4B423EFC99FA2014F16883A311F403FC2A5D80CEFECEB6FF009E09FF007DBFF8D28D3EDD4E442A0FB3BFF8D687D9C7FC" & _
"F46FD28FB38FF9E8DFA51A08A91DBAC4DB91707FEBA39FEB53442537419A4CA76403A7152FD9C7FCF46FD283088C6EDEE71DB028BA03E75B0F89BE224B3B3847D88A8B389D7F7072382B8FBDFEC8AB6DF157C431C" & _
"59F234D6C7ADBB73FF8F51452190FFC2DEF117FCFAE97FF007E1BFF008AA2CBE2DF892F35BB5B13069691CD288CB0B66247CB9CFDFA28A4F613D8AE3E317898D899FECFA56E168D718FB3363224D98FBFD31525CF" & _
"C5EF12C17AF6E21D2C859D22CFD99BA326ECFDFEB451551D69DFCFFCC5276A96FEBA0ABF173C4C74E86EBC9D2B749652DCEDFB2B601490A01F7FA1C66A78BE2AF8924BA68BCBD3005BAB6833F666CE255249FBFD4" & _
"628A29C9593F4FD0E8515CB4FCDBFCCA56FF18BC4D34F731B5BE9404514B2022D9B928703F8EA3D5BE34789AC2F04315AE9254A06F9ADDB3CFF00C0E8A2A56C67256651FF0085EBE2AFF9F3D1FF00F019FF00F8BA" & _
"D1B6F8C7E279AD44C6DF4A049C605B37FF00174514D0A3ABFBFF0026599BE2D789A0B759D63D2F27903ECADC700FF7E9F71F193C5B06E651A59DAB1B0DD6ADFC48A4FF001FFB545143262F43FFD9"

_GDIPlus_Startup()
$timer = TimerInit()
Dim $DemoPicture[10]
    Local $hGUI = GUICreate("Example",1200)
      For $i = 1 To 9
        $DemoPicture[$i] = GUICtrlCreatePic("",10+120,10 ,111,69)
      Next
    GUISetState(@SW_SHOW, $hGUI)
    While 1
        If TimerDiff($timer) > 250 Then
            _Set_PreviewPic()
            $timer = TimerInit()
        EndIf

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                _GDIPlus_Shutdown()
            Exit
        EndSwitch
    WEnd


;===================================================================================================
Func _Set_PreviewPic()
      For $i = 1 to 9
        Global $Bmp_Logo = _GDIPlus_BitmapCreateFromMemory(Binary($pic), True)
        _WinAPI_DeleteObject(GUICtrlSendMsg($DemoPicture[$i -1], 0x0172, 0, $Bmp_Logo))
        _WinAPI_DeleteObject($Bmp_Logo)
    Next
EndFunc

 


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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks for your help! :-) I´ve fixed it.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

On 9/5/2016 at 9:59 AM, UEZ said:

use _GDIPlus_BitmapCreateFromMemory instead:

I fixed your example and added a question to the code.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Memory.au3>
#include <Constants.au3>
#include <APIConstants.au3>
#include <WinAPIEx.au3>
#include <GDIPlus.au3>

Global $pic = "0xFFD8FFE000104A46494600010101006000600000FFDB004300080606070605080707070909080A0C140D0C0B0B0C1912130F141D1A1F1E1D1A1C1C20242E2720222C231C1C2837292C303134" & _
        "34341F27393D38323C2E333432FFDB0043010909090C0B0C180D0D1832211C213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232FFC0" & _
        "0011080045006F03012200021101031101FFC4001F0000010501010101010100000000000000000102030405060708090A0BFFC400B5100002010303020403050504040000017D010203000411051221314106135" & _
        "16107227114328191A1082342B1C11552D1F02433627282090A161718191A25262728292A3435363738393A434445464748494A535455565758595A636465666768696A737475767778797A838485868788898A92" & _
        "939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD2D3D4D5D6D7D8D9DAE1E2E3E4E5E6E7E8E9EAF1F2F3F4F5F6F7F8F9FAFFC4001F010003010101010101010101000000000" & _
        "0000102030405060708090A0BFFC400B51100020102040403040705040400010277000102031104052131061241510761711322328108144291A1B1C109233352F0156272D10A162434E125F11718191A26272829" & _
        "2A35363738393A434445464748494A535455565758595A636465666768696A737475767778797A82838485868788898A92939495969798999AA2A3A4A5A6A7A8A9AAB2B3B4B5B6B7B8B9BAC2C3C4C5C6C7C8C9CAD" & _
        "2D3D4D5D6D7D8D9DAE2E3E4E5E6E7E8E9EAF2F3F4F5F6F7F8F9FAFFDA000C03010002110311003F00F43F0F476371A4DA241A3586C8ADA2DC64857712541EE3DFD6B50D8C276FFC49B4B1C7CDFBA4E3E9C5647851" & _
        "99747CA3EC6F220C367FD85ADDDD330E2EB3EDB8FF0085525A5C4EE34585893CE97A6A0EE0C2991FA5595D2F4EC67FB274F39E47EE13FC29D6D2AA902493730E98C9AB5E6AFF00B5FF007C9A2C172AFF0065E9FF0" & _
        "0F408B0FF00BF09FE14874DD395493A4586075FDC2FF855EA8E74596DE48DC651D4AB0F5078345905CA89A769D20529A35890C32316E9C8FCA9DFD9563FF404B2FF00BF09FE1459E9D0E9D149158DA98813B87CE4" & _
        "F38C7727D2A6265C054C72410339C71CD0D2BE809BB6A51F2B46DFB3FB374EDD9C63C84EBF954E34CB0270345B2CFF00D704FF000AB6824E59D09939C3638A512DC023CC3B41F503FC693B741E854FECAB1FFA025" & _
        "97FDF84FF000A3FB2AC7FE80965FF007E13FC2ADA4B741097049C7040039FCE93CE9FCADE3249E70481B690157FB2AC7FE80965FF0080E9FE14A9A569E5C03A2D9007BFD9D3FC2AC3CB73B772B30F98F18078A485" & _
        "A49258E4954BB2B1D8781D41CD311CB783235974F457195FB3C271FF00005AE8F33F4B711951D986306B9EF0467EC31FA7D9E2CFFDF0B5D14B03846F2E57F60339CFE1551DAC0C7AFDA304385C9E8CBD054B87FEF" & _
        "8FF00BE6A92DC3A12AEED9538CB77FD2AD89E2C03E628CFA9A7664DD10FDA18C8F1AB0DC879E073EFD7F0A7EF9361661F20EA70063F5A85994BEE0D95F6A953849B9E88BFCEA1B2922CBC2F7080661684E0E369E4" & _
        "7D73527D993733796996CE793CE6B28118EA78A3B0393EB486688B4DB26E558C00723AFE348C9042E3708D5BA8CB1AA0AC83AE79071569BE49AD413D7FA9A009E211094F97E5EFC73863D29ED29DED1A9432019DA" & _
        "0F354E690477BB893C376A74D2C62E564704A119C7E14011C5752C92DC46F6EC3CA048391F376C8AB70B6F287CBDBF363EF67B1AAA0B0BB99A385A42C8C0E0E3BF152DABCA5D55EDD917767248F43403D5E872DE0" & _
        "9FF8F24E7A5BC5C7FC016BAB6018608C835CAF823FE3C17FEBDE1FFD016BAAAA4265792D622A4E76F724F354641B5CC6B965EC4569C85C6368E0F538C9150BDBC6F21674959BB91C0356ADD497E4410E5A143B40C" & _
        "83C63A73565492B2E17AA2FE1CD401638C2A0C8001C063CF7A7875CB00C3050679AC8B18338238A067A714D52983C8EA7BD2AB217392383C73ED400B8385E9C0AB4EDBE7B5C0EC3F9D55CC617823F3F6A9F72F9F6" & _
        "C770E9EBEF4005C296BA20773E99A59223248A819570A012DC76F4A19946A00EE1F7BAE6A47F2DF51504839F7F6A007DB0C5CC83D33FCEACBFDE8FFDEFE86ABDBFFC7DCBF53FCEAC3FDE8FFDEFE868038AF047FC7" & _
        "8A7FD7BC5FF00A02D7532063190B9DDDB158BA169B2268B632420C65ED6225978CFC82B4C5ADD6465A5C77C3D52690AC519649A299D55CAE58903763F1A4135C7FCF57EBCFCDDAAFF00D81C60EE9CF73C83CD3D6C" & _
        "64CE0493A81FED0A7A770B1523FB2C8ECF2A1DC3B9CE0FEA6A422C08E1579E9C1A9CD84BCE1E6E4FF7874A4FECF97FE7A4BF98A7602A95B36DD911124F07CB3C500DB05FF96617B7EE6AF8B5942E324FFC0579A3E" & _
        "CD371C9C63A6D5A561953C9B494A868A3DC471F7973F91A5FECFB43D228FF00EFE37F8D5F4B423EFC99FA2014F16883A311F403FC2A5D80CEFECEB6FF009E09FF007DBFF8D28D3EDD4E442A0FB3BFF8D687D9C7FC" & _
        "F46FD28FB38FF9E8DFA51A08A91DBAC4DB91707FEBA39FEB53442537419A4CA76403A7152FD9C7FCF46FD283088C6EDEE71DB028BA03E75B0F89BE224B3B3847D88A8B389D7F7072382B8FBDFEC8AB6DF157C431C" & _
        "59F234D6C7ADBB73FF8F51452190FFC2DEF117FCFAE97FF007E1BFF008AA2CBE2DF892F35BB5B13069691CD288CB0B66247CB9CFDFA28A4F613D8AE3E317898D899FECFA56E168D718FB3363224D98FBFD31525CF" & _
        "C5EF12C17AF6E21D2C859D22CFD99BA326ECFDFEB451551D69DFCFFCC5276A96FEBA0ABF173C4C74E86EBC9D2B749652DCEDFB2B601490A01F7FA1C66A78BE2AF8924BA68BCBD3005BAB6833F666CE255249FBFD4" & _
        "628A29C9593F4FD0E8515CB4FCDBFCCA56FF18BC4D34F731B5BE9404514B2022D9B928703F8EA3D5BE34789AC2F04315AE9254A06F9ADDB3CFF00C0E8A2A56C67256651FF0085EBE2AFF9F3D1FF00F019FF00F8BA" & _
        "D1B6F8C7E279AD44C6DF4A049C605B37FF00174514D0A3ABFBFF0026599BE2D789A0B759D63D2F27903ECADC700FF7E9F71F193C5B06E651A59DAB1B0DD6ADFC48A4FF001FFB545143262F43FFD9"

_GDIPlus_Startup()
$timer = TimerInit()
Dim $DemoPicture[10]
Local $hGUI = GUICreate("Example", 1200)
For $i = 0 To 8
    $DemoPicture[$i + 1] = GUICtrlCreatePic("C:\Users\Owner\Pictures\black.jpg", 10 + ($i * 120), 10, 111, 69)
Next
GUISetState(@SW_SHOW, $hGUI)
_Set_PreviewPic(); <-- why no just this ?
While 1
    If TimerDiff($timer) > 250 Then ; <-- why like this ? ; to test memory leak :)
        _Set_PreviewPic()
        $timer = TimerInit()
    EndIf

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            _GDIPlus_Shutdown()
            Exit
    EndSwitch
WEnd

;===================================================================================================
Func _Set_PreviewPic()
    For $i = 1 To 9
        Global $Bmp_Logo = _GDIPlus_BitmapCreateFromMemory(Binary($pic), True)
        _WinAPI_DeleteObject(GUICtrlSendMsg($DemoPicture[$i], 0x0172, 0, $Bmp_Logo))
        _WinAPI_DeleteObject($Bmp_Logo)
    Next
EndFunc   ;==>_Set_PreviewPic

why the reload every so often ?, got it, testing memory leak, never mind :) 

Edited by argumentum

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now