Jump to content

Script & Memory Usage


Recommended Posts

I would be grateful if someone could explain to me why function "_Test2()" doesn't consume much memory while function "_Test1()" uses more and more memory. Functions should do the same thing. This happens in the case when a prerequisite is met so please do that.

Please run the script with "_Test1()" and "_Test2()" function and then observe the Memory usage through "Task Manager" in both cases. Once again, would be grateful if someone could explain.

Prerequisite ... create file "@ScriptDir & '\test.txt'" and deny yourself read/write rights on it.

; Prerequisite ... create file "@ScriptDir & '\test.txt'" and deny yourself read/write rights on it.
; File can be empty or have one line of TXT or whatever ...

Dim $t = 0, $f = 1
If MsgBox (262180, 'TEST', 'Do you wish to use function "_Test2"?') = 6 Then $f = 2
While 'TEST'
    Switch $f
        Case 1
            _Test1(@ScriptDir & '\test.txt')
        Case 2
            _Test2(@ScriptDir & '\test.txt')
    EndSwitch
    If @error AND MsgBox (262144, 'TEST', 'Prerequisite not met. Exiting.', 5) Then ExitLoop
    If $t = 1000 AND MsgBox (262180, 'TEST', 'Do you wish to STOP?') = 6 Then ExitLoop
    $t += 1
    If $t > 1000 Then $t = 0
    Sleep (5)
WEnd
Exit


Func _Test1($File = '')
    If $File = '' OR NOT FileExists ($File) Then Return SetError (1, 0, 'ERROR')
    $FileHandle = FileOpen ($File, 0)
        FileReadLine ($FileHandle, 1)
    FileClose ($FileHandle)
    Return SetError (0, 0, '')
EndFunc ;=>_Test1

Func _Test2($File = '')
    If $File = '' OR NOT FileExists ($File) Then Return SetError (1, 0, 'ERROR')
    FileReadLine ($File, 1)
    Return SetError (0, 0, '')
EndFunc ;=>_Test2
Edited by toofat
Link to comment
Share on other sites

I can replicate the problem under Win7 x64.

FileOpen is returning -1, indicating failure, but for some reason memory is used.

Obviously FileReadLine and FileClose will just plain fail with the invalid handle.

I can't find an open ticket on it, but it looks like a bug.

Link to comment
Share on other sites

friends....

How can i get text of the cursor position with out click on it

By using cursor position only

first ... get your own post ... :unsure:

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
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...