Jump to content

Error Allocating Memory


Accension
 Share

Recommended Posts

Having some trouble w/ this code. After a while it runs out of memory. I added a 100 ms delay but that only makes it run longer, but it still eventually runs out of memory.

$input = "c:\Users\Admin\Scripts\Var\request.txt"

$destination = "c:\Users\Admin\Scripts\Var\request2.txt"

; set esc hotkey

HotKeySet("{ESC}", "Terminate")

; set delay between keys default: 5

; 50 = telnet speed

AutoItSetOption("SendKeyDelay",50)

$file = "1"

; Iterates every new set of instructions

While CheckInput($input,$file)

; Open putty session and login

Run("C:\putty\putty.exe")

WinWaitActive("[CLASS:PuTTYConfigBox]")

Send("{TAB 4}{DOWN 2}{ENTER}")

WinWaitActive("[CLASS:PuTTY]")

Sleep(500)

Send("speed{ENTER}")

Sleep(500)

Send("speed{ENTER}")

Sleep(500)

Send("{ENTER}")

Sleep(1000)

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

Send($line)

WEnd

FileMove($input,$destination,1)

Sleep(2000) ; need time for the file to move

Wend

Func CheckInput($input,ByRef $file)

$file = FileOpen($input, 0)

While $file = -1

$file = FileOpen($input, 0)

Sleep(100)

WEnd

Return 1

EndFunc

Func Terminate()

Exit 0

EndFunc

Link to comment
Share on other sites

You forgot to FileClose the handle. See FlieOpen and FileClose in the helpfile.

I will try that, however, the program doesn't run out of memory while it's working, it actually runs out of memory when it's idle in that CheckInput function. (At least that is what I believe based on the behavior).

Link to comment
Share on other sites

You forgot to FileClose the handle. See FlieOpen and FileClose in the helpfile.

I set the fileclose, but I notice in task manager the program keeps getting larger and larger in memory

$input = "c:\Users\Admin\Scripts\Var\request.txt"
$destination = "c:\Users\Admin\Scripts\Var\request2.txt"


; set esc hotkey
HotKeySet("{ESC}", "Terminate")
; set delay between keys default: 5
; 50 = telnet speed
AutoItSetOption("SendKeyDelay",50)

$file = "1"

; Iterates every new set of instructions
While CheckInput($input,$file) 
    
    ; Open putty session and login
    Run("C:\putty\putty.exe")
    WinWaitActive("[CLASS:PuTTYConfigBox]")
    Send("{TAB 4}{DOWN 2}{ENTER}")
    WinWaitActive("[CLASS:PuTTY]")
    Sleep(500)
    Send("speed{ENTER}")
    Sleep(500)
    Send("speed{ENTER}")
    Sleep(500)
    Send("{ENTER}")    
    Sleep(1000)
    
    While 1 
        $line = FileReadLine($file)
        If @error = -1 Then ExitLoop
        Send($line)
    WEnd
    
    FileClose($file)
    
    FileMove($input,$destination,1)
    Sleep(2000) ; need time for the file to move
Wend






Func CheckInput($input,ByRef $file)
    $file = FileOpen($input, 0)
    While $file = -1
        $file = FileOpen($input, 0)
        Sleep(100)
    WEnd
    FileClose $file
    Return 1
EndFunc


Func Terminate()
    Exit 0
EndFunc
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...