Jump to content

StdoutRead Memory Problem (EDIT: and StdioClose)


Recommended Posts

This seems to be much better and doesn't increase memory like your example:

#include <Constants.au3> ;This allows the use of the $STDERR_MERGED variable
HotKeySet("{ESC}","MyExit")  ; This lets you easily get out of the While loop by using the ESC key

While 1
    $pid = Run("notepad.exe","",@SW_SHOW,$STDERR_MERGED)  ;It doesn't matter what program you run here.
    ProcessWait($pid) ;Wait until the exe starts
    ProcessClose($pid) ;Close the exe
    ProcessWaitClose($pid) ;Wait until the exe is actually closed
    StdioClose($pid) ;Close the StdIO to the exe to release the handles and memory 
    Sleep(1000) ;Wait 1 second, it doesn't really matter how long you wait here.
WEnd
Func MyExit() ;Exit the program
    Exit
EndFunc

 Jos

Interesting, I do not see any memory increase with your example.  It looks like the only difference is that you processclose before stdioclose.  Why should the order of those 2 things matter?

 

 

Link to comment
Share on other sites

I can confirm that the reproducer provided by ferbfletcher does indeed have a memory leak, but only when used with $STDERR_MERGED. We probably should treat this as a bug from here on out so I have created ticket https://www.autoitscript.com/trac/autoit/ticket/3135 

You can try to run the following simplified code and observe the memory usage:

#include <Constants.au3>

While 1
    $pid = Run("ping localhost","", @SW_HIDE, $STDERR_MERGED)
    ProcessWait($pid)
    StdioClose($pid)
    ProcessClose($pid)
    ProcessWaitClose($pid)
WEnd

@ferbfletcher Many thanks for taking the time to provide a reproduction script to get to the bottom of this. It is very much appreciated and we'll take it from here, assuming your problem is solved adequately.

Edited by jvanegmond
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...