Jump to content

Question about memory use


Recommended Posts

I have a script that checks a certain directory for any files named *.mgp. I use _FileLstToArray to check for the files:

$aMPG_FILES = _FileListToArray($sMPG_DIRECTORY, "*.mpg", 1)

I have the script run continuously--checking every 5 seconds. The script is using more memory than I expected it would. When I dump some files (maybe 50) into the directory that the script is checking, task manager shows that the script is now using even more memory. If I dump a larger amount of files (100 or more) into the directory, the task manager shows me that even more memory is being used.

I have a couple of questions:

Is the memory use going up because the array created with _FileListToArray has to get bigger when it returns a larger number of files?

Is there a way to free up the memory to the OS?

Should I even be worrying about this?

Currently, after throwing 190 files, the simple script is using 5,868 K per Windows Task Manager. Does that sound like a lot for such a small, simple script?

Link to comment
Share on other sites

I have a script that checks a certain directory for any files named *.mgp. I use _FileLstToArray to check for the files:

$aMPG_FILES = _FileListToArray($sMPG_DIRECTORY, "*.mpg", 1)

I have the script run continuously--checking every 5 seconds. The script is using more memory than I expected it would. When I dump some files (maybe 50) into the directory that the script is checking, task manager shows that the script is now using even more memory. If I dump a larger amount of files (100 or more) into the directory, the task manager shows me that even more memory is being used.

I have a couple of questions:

Is the memory use going up because the array created with _FileListToArray has to get bigger when it returns a larger number of files?

Is there a way to free up the memory to the OS?

Should I even be worrying about this?

Currently, after throwing 190 files, the simple script is using 5,868 K per Windows Task Manager. Does that sound like a lot for such a small, simple script?

If your array is being resized each time through the loop, then you should see a certain usage with only 1 file, see it go up when you add more files, then see it go down again when you remove files. Are you seeing it go down again when you reduce the number of files?

This demo, when compiled and run, uses 3,604K on my computer:

HotKeySet ("{ESC}", "_Quit")
While 1
    Sleep(20)
WEnd
Func _Quit()
    Exit
EndFunc

:)

P.S. Hmm... doesn't work that way. I ran this demo version to see if I could detect the memory usage go up and down:

HotKeySet ("{ESC}", "_Quit")
Global $avTest[1] = [0]
While 1
    ReDim $avTest[1000]
    For $n = 0 To 999
        $avTest[$n] = Random()
    Next
    Sleep(5000)
    
    ReDim $avTest[1]
    Sleep(5000)
WEnd
Func _Quit()
    Exit
EndFunc
It runs steady at 3,632K usage. So the AutoIt run time does not release resources, at least with this simple test.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

If your array is being resized each time through the loop, then you should see a certain usage with only 1 file, see it go up when you add more files, then see it go down again when you remove files. Are you seeing it go down again when you reduce the number of files?

This demo, when compiled and run, uses 3,604K on my computer:

HotKeySet ("{ESC}", "_Quit")
While 1
    Sleep(20)
WEnd
Func _Quit()
    Exit
EndFunc

:)

Nope. It the mem usage never goes down. After I dump the files into the directory, the script copies them out but the mem stay the same. Here's my crappy script:

; Infinite loop
While True
   ; Get all the files in the MPG directory that have a .mpg extension
    $aMPG_FILES = _FileListToArray($sMPG_DIRECTORY, "*.mpg", 1)
    
    
    
; If @error equals 4, there were no files found
; if no files were found we don't go through this loop
    If @error <> 4 Then
  
       ; the first array element is the number of files found
    ; we want to remove that crappy element since we can't use it
        _ArrayDelete($aMPG_FILES, 0 )
        
       ; Lets go through all the files found
        for $File in $aMPG_FILES
           ; change the extension
            local $sNew_File = StringRegExpReplace($File, ".mpg", ".trp")
           ; and move the files to the TRP folder
            FileMove($sMPG_DIRECTORY & $File, $sTRP_DIRECTORY & $sNew_File)
        Next
        
    EndIf
    
; Duh!
    Sleep( 5 * 1000)
    
WEnd

I since changed a portion to:

Do
               ; change the extension
                local $sNew_File = StringRegExpReplace($aMPG_FILES[0], ".mpg", ".trp")
               ; and move the files to the TRP folder
                FileMove($sMPG_DIRECTORY & $aMPG_FILES[0], $sTRP_DIRECTORY & $sNew_File)
                _ArrayDelete($aMPG_FILES, 0 )
            Until Ubound($aMPG_FILES) == 1

Thinking that as it used the array elements it would delete them and make the array smaller (clean up) and therefore free up the memory but it doesn't seem to work much better.

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