Jump to content

Possible Memory/GDI leak with GUICtrlSetImage() ?


Fur
 Share

Recommended Posts

I made a simple slideshow app to learn about using the new GUI stuff. I use it to cycle through my WoW screencaps. (I know there are lots of better ways of doing this, just needed something to code up!)

Anyways, I noticed the app's memory and GDI object count rapidly climbing with each click! I didn't see any means of releasing the old images object myself.. Please enlighten me!

;
; Simple WoW screenshot slide show
;
#include <GUIConstants.au3>

Local $console = GuiCreate("World of Warcraft", 810, 640, 0, 0, $WS_SIZEBOX+$WS_SYSMENU)
$n=GUICtrlCreatePic("wow1.bmp",-4,-30, 0, 0)
GUISetState (@SW_SHOW, $console)      ; will display an empty dialog box

Local $file_list = ""
Local $search = FileFindFirstFile("*.bmp")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    if $file_list = "" Then
    $file_list = $file
    Else
    $file_list = $file_list & "|" & $file
    Endif
WEnd

Global $frame_list = StringSplit($file_list, "|")
Global $frame_index = 1;

while 1 = 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    if $msg = $n Then
     AdvanceFrame()
    Endif
WEnd

Func AdvanceFrame()
    $frame_index = $frame_index + 1
    if $frame_index >= UBound($frame_list) Then
        $frame_index = 1;
    Endif

    Local $img = $frame_list[$frame_index]
    WinSetTitle("World of Warcraft", "", "World of Warcraft - " & $img)
    GUICtrlSetImage($n, $img)
Endfunc

Exit
Link to comment
Share on other sites

I made a simple slideshow app to learn about using the new GUI stuff.  I use it to cycle through my WoW screencaps.  (I know there are lots of better ways of doing this, just needed something to code up!)

Anyways, I noticed the app's memory and GDI object count rapidly climbing with each click!  I didn't see any means of releasing the old images object myself.. Please enlighten me!

;
; Simple WoW screenshot slide show
;
#include <GUIConstants.au3>

Local $console = GuiCreate("World of Warcraft", 810, 640, 0, 0, $WS_SIZEBOX+$WS_SYSMENU)
$n=GUICtrlCreatePic("wow1.bmp",-4,-30, 0, 0)
GUISetState (@SW_SHOW, $console)      ; will display an empty dialog box

Local $file_list = ""
Local $search = FileFindFirstFile("*.bmp")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    if $file_list = "" Then
    $file_list = $file
    Else
    $file_list = $file_list & "|" & $file
    Endif
WEnd

Global $frame_list = StringSplit($file_list, "|")
Global $frame_index = 1;

while 1 = 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    if $msg = $n Then
     AdvanceFrame()
    Endif
WEnd

Func AdvanceFrame()
    $frame_index = $frame_index + 1
    if $frame_index >= UBound($frame_list) Then
        $frame_index = 1;
    Endif

    Local $img = $frame_list[$frame_index]
    WinSetTitle("World of Warcraft", "", "World of Warcraft - " & $img)
    GUICtrlSetImage($n, $img)
Endfunc

Exit

<{POST_SNAPBACK}>

Thanks it was a bug I think I fix it try next upload after 165 if Jon have time to put it in the next one.

Cheers

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...