Cleaning the current environment after a fork

Diez B. Roggisch deets at nospam.web.de
Thu Apr 6 06:47:25 EDT 2006


> I want to fork a process, but my scope has lots of stuff that the child
> won't need. Is it possible to clean the current environment of cruft so it
> is collected and freed? Basically I want it to go something like this.
> This is my first forking Python app, by the way:

I'm not an expert of this - but if all the reason you want to do this are
memory concerns, AFAIK forking will only make a copy of those memory-pages
that are actually written to by the forked process - for efficiency
reasons.

And even if that wasn't the case: I think as long as you don't run into
memory-troubles, don't do it. Its complex, flaky and thus an unnecessary
source of failure.

Diez



More information about the Python-list mailing list