Jump to content

StdoutRead() increases number of handles, is this normal?


VAN0
 Share

Recommended Posts

While investigating an issue with StdoutRead(), I came across a strange thing, every time StdoutRead() is used it increases number of handles:

#include <Misc.au3>
While 1
    Local $iPID = Run(@ComSpec & " /c WMIC PROCESS WHERE Name='autoit3.exe' GET handlecount", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    ProcessWaitClose($iPID)
    Local $sOut = StdoutRead($iPID)
    StdioClose($iPID)
    ConsoleWrite("out=" & StringStripWS($sOut, 4) & @CRLF)
    Sleep(1000)
WEnd

The number increases based on number of channels. In this example there are two channels $STDERR_CHILD and $STDOUT_CHILD so it increases by 2

The memory usage doesn't increase, just the handle count. Is this supposed to be like this? Shouldn't StdioClose() clean up or something?

Link to comment
Share on other sites

  • 1 month later...

Hi,

I came across the increasing handle count before, but as you mentioned already, a Stdioclose($PID) is cleaning that up.

 

On my system I cannot confirm, that it's increasing by the time:

 

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\temp\test.au3" /UserParams    
+>15:19:35 Starting AutoIt3Wrapper v.18.708.1148.0 SciTE v.4.1.0.0   Keyboard:00000407  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\admin.AD\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\admin.AD\AppData\Local\AutoIt v3\SciTE 
+>Check for missing standard constants/udf include files: 1 include(s) were added
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\temp\test.au3
+>15:19:36 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
out=HandleCount 331 193 165 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 
out=HandleCount 331 193 164 

>Process failed to respond; forcing abrupt termination...
>Exit code: 1    Time: 31.04

 

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

@VAN0  I get the same result as you on Win7 (3.3.16.1).  After looking a little deeper on it, any kind of run (even a simple dir) will increase the number of handles.

Edit : if you use $STDOUT_CHILD or $STDERR_MERGED only, the increase is only one.  So it seems related to the stream.  Might be worth asking the dev ( @jpm @Jos )

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