Jump to content

FileReadLine Leaking


 Share

Recommended Posts

Looking for some help on this.

I have a chat bot that watches a log file for new entries. If the line is directed towards the bot it is acted on. This technique of FileReadLine() in a loop to watch the end of a file being written to has worked for me for a long time. Since the latest version I've been leaking memory to a max of 2 gig in about 2 hours.

Here is an extremely over simplified version of the bot to demonstrate the leak. Normally I loop every 1/4 second but in this example I've sped it up for full effect.

; Leak example
;

; Create empty file for this test.
$tmpFile=FileOpen("MyChatLog.txt",2)
FileClose($tmpFile)
Sleep(1000)

; Open File for reading
$theLog=FileOpen("MyChatLog.txt",0)

; Watch for additions to the end of the file
While 1
    $NewData=FileReadLine($theLog)
    if $NewData<>"" then
        ParseData()
    EndIf
    Sleep(10)

WEnd

Func ParseData()
    If StringInStr($NewData,"hi") Then
        MsgBox(0,"","Hi to you too!")
    EndIf
EndFunc

You can watch with your favorite process manager as autoit chews through the memory.

Thanks for anyone who can help me with this.

Fz

Link to comment
Share on other sites

  • Moderators

Must be something on your PC, that has 0% CPU usage for me.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

It seems to me that example using AutoIt3A doesn't leak, only Unicode version does.

Edit:

Also it seems that if the txt file is in Unicode format, Unicode AutoIt doesn't leak either.

So maybe it has something to do with ANSI-to-UTF conversion it does.

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

It seems to me that example using AutoIt3A doesn't leak, only Unicode version does.

Edit:

Also it seems that if the txt file is in Unicode format, Unicode AutoIt doesn't leak either.

So maybe it has something to do with ANSI-to-UTF conversion it does.

Wow, good find. That will certainly get my bot back in business. Timmy bot thanks you!

And me too. :rolleyes:

Link to comment
Share on other sites

  • Moderators

Yep...shouldn't use much CPU. How about the RAM?

It seems to me that example using AutoIt3A doesn't leak, only Unicode version does.

Edit:

Also it seems that if the txt file is in Unicode format, Unicode AutoIt doesn't leak either.

So maybe it has something to do with ANSI-to-UTF conversion it does.

Yes... Quickly looked, and didn't look at your actual post concern...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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