[squeak-dev] Error: ExternalUnixOSProcess not garbage-collected

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Error: ExternalUnixOSProcess not garbage-collected

Winfried Jacobs
Hello list,

I have a problem with  ExternalUnixOSProcess objects. In my squeak
program I create them a lot, but they do not get garbage-collected, and
after 1200 of  them are created, the program stops with an error:
'cannot create OS pipe' (error thrown in External pipe>>makePipe).

The following script demonstrates what is going on:

"### Script ###"

    1500 timesRepeat: [
         p := PipeableOSProcess command: 'ls'.

            "these commands don't make a difference ... :"
            "p  finalize."
            "p release."
            "p processProxy finalize."
            "p close; closePipes."

        Transcript
            show: PipeableOSProcess allInstances size;
            show: '-';
            show: ExternalUnixOSProcess allInstances size;
            space.
    ] .

    Smalltalk garbageCollect.

"### End of Script ###"

The Transcript shows that the number of PipeableOSProcess instances
stays constant (more or less), while the number of ExternalUnixOSProcess
instances goes up, and I have no idea how to get rid of them.

After restarting the squeak image (save-quit-start) the
ExternalUnixOSProcess objects are gone.

The configuration:

    - vm-version: Squeak3.9alpha on a Ubuntu Linux
    - image version: Squeak 3.9  ("Ramon Leon's image")
    - 'OSProcess versionInformation' gives:
        - OSProcess version 4.3.6
        - CommandShell version 4.3.2  (not installed in this image)

Does anybody have an idea what's possibly wrong?

Thank you in advance
Winfried




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Error: ExternalUnixOSProcess not garbage-collected

David T. Lewis
On Thu, Apr 17, 2008 at 01:17:08AM +0200, Winfried Jacobs wrote:

> Hello list,
>
> I have a problem with  ExternalUnixOSProcess objects. In my squeak
> program I create them a lot, but they do not get garbage-collected, and
> after 1200 of  them are created, the program stops with an error:
> 'cannot create OS pipe' (error thrown in External pipe>>makePipe).
>
> The following script demonstrates what is going on:
>
> "### Script ###"
>
>    1500 timesRepeat: [
>         p := PipeableOSProcess command: 'ls'.
>
>            "these commands don't make a difference ... :"
>            "p  finalize."
>            "p release."
>            "p processProxy finalize."
>            "p close; closePipes."
>
>        Transcript
>            show: PipeableOSProcess allInstances size;
>            show: '-';
>            show: ExternalUnixOSProcess allInstances size;
>            space.
>    ] .
>
>    Smalltalk garbageCollect.
>
> "### End of Script ###"

Hi Winfried,

To kill an external OS process, use #terminate.

The reason that you are running out of pipes is that the processes
are still running. If you do "p upToEnd" to read the output of the
command, it will complete normally. If you do "p terminate", it will
complete abnormally, and either way the pipes will be cleaned up.
The limit on number of open pipes (file handles) is imposed by the
operating system.

The reason that your external processes are not garbage collected is
that there is a reference to them in the process proxy for your
Squeak VM (OSProcess thisOSProcess allMyChildren). If you want to
clean this up, you can do "OSProcess thisOSProcess discardExitedChildren"
or "OSProcess thisOSProcess resetChildProcessDictionary". This is
not done automatically, which could become a problem if you have a
very long-running Squeak image I suppose.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Error: ExternalUnixOSProcess not garbage-collected

Winfried Jacobs
Hello David,

great, thanks a lot for your explanation!  Now I'm doing "OSProcess
thisOSProcess discardExitedChildren"  every 10 minutes, and since then
the image has been running for days without a problem.

Thanks,
Winfried

 
David T. Lewis schrieb:

>
> Hi Winfried,
>
> To kill an external OS process, use #terminate.
>
> The reason that you are running out of pipes is that the processes
> are still running. If you do "p upToEnd" to read the output of the
> command, it will complete normally. If you do "p terminate", it will
> complete abnormally, and either way the pipes will be cleaned up.
> The limit on number of open pipes (file handles) is imposed by the
> operating system.
>
> The reason that your external processes are not garbage collected is
> that there is a reference to them in the process proxy for your
> Squeak VM (OSProcess thisOSProcess allMyChildren). If you want to
> clean this up, you can do "OSProcess thisOSProcess discardExitedChildren"
> or "OSProcess thisOSProcess resetChildProcessDictionary". This is
> not done automatically, which could become a problem if you have a
> very long-running Squeak image I suppose.
>
> Dave
>
>
>