Jump to content

Memory leak


Recommended Posts

What can couse a memory leak in a script ?

i declared all the Var's and all Func vars are local

i even placed Var = Func to make sure the return value (not needed) doesnt leak so what can it be ?

my program keeps getting bigger and bigger in the taskmanager mem usage

Link to comment
Share on other sites

What can couse a memory leak in a script ?

i declared all the Var's and all Func vars are local

i even placed Var = Func to make sure the return value (not needed) doesnt leak so what can it be ?

my program keeps getting bigger and bigger in the taskmanager mem usage

maybe if we could see your script or a sample script we could help.

Edit: damn, to slow :)

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

Here is what I tried:

#Include <A3LGDIPlus.au3>
#Include "FileListToArrayEX.au3"
#include <Array.au3>

$Folder = IniRead(@ScriptDir & "\Data.ini", "Wallpaper", "folder", "")
$Sleep = Number(IniRead(@ScriptDir & "\Data.ini", "Wallpaper", "time_in_ms", 1000))

$pictureArray = _FileListToArrayEx($Folder, '*.jpg;*.bmp', 1, '', False)
;_ArrayDisplay($pictureArray)

HotKeySet("+!^w", "_ChangeWallpaper")

While 1
    If IniRead(@ScriptDir & "\Data.ini", "Wallpaper", "Slide", "") = "True" Then 
        _ChangeWallpaper()
    EndIf
    Sleep($Sleep)
WEnd

Func _ChangeWallpaper()
    
    RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0')
    RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2')
    
    ;Randomize next wallpaper instead of grabbing next one
    $CurrentFile = $Folder & $pictureArray[Random(1,$pictureArray[0], 1)]
    
    ;If file is jpg, convert to bmp and store in temp directory
    Switch StringRight($CurrentFile, 3)
        Case "jpg"
            $result = _GDIP_StartUp()
            If NOT $result Then 
                MsgBox(0,"","Error calling _GDIP_StartUp()")
                Exit
            EndIf
            
            $hImage = _GDIP_ImageLoadFromFile ($CurrentFile)
            
            $sCLSID = _GDIP_EncodersGetCLSID ("BMP")
            If $sCLSID Then MsgBox(0,"","Error retrieving clsid")
            
            _GDIP_ImageSaveToFileEx ($hImage, @TempDir & "\999.bmp", $sCLSID)
            _GDIP_ShutDown ()
            $CurrentFile = @TempDir & "\999.bmp"
            
        Case "bmp"
            ;Do nothing
    EndSwitch
    
    RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $CurrentFile)
    DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $CurrentFile, "int", 0)
    TrayTip ( "Wallpaper", "Changed to " & $CurrentFile, 10)

EndFunc

But there is always an error calling _GDIP_StartUp() despite running a fully updated copy of XP Pro

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...