Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: exec with cleanup

by andyf (Pilgrim)
on Jun 07, 2004 at 14:19 UTC ( [id://361987]=note: print w/replies, xml ) Need Help??


in reply to exec with cleanup

Im guessing this is for an embedded app Bart, or for some reason you're carefully counting memory bytes. At the point of exit my understanding is that the only references still in scope will be the builtins (@INC, @ARGS etc) and any globals. All objects should have been undef, and you are not inside a block that is holding onto any references the memory usage should be minimal.
Let's clarify the problem further. Are you fearing a leak because the external program will never return execution to your first script? If so, how about forking? After spawning the external prog the script will continue through to a normal exit and cleanup.
Alternatively you could go right outside the box and realise that you could call both the original script and the followup program in sequence from another place.
Addition:
Perls garbage collection is very solid. From pp.451 of the Cookbook (Ram)
"So you're guaranteed that an object eventually gets properly destroyed, unless a program never exits." GC gets called bigtime when the interpreter shuts down. So another (horrible) solution presents itself, just get the followup program to kill its parent when it dies.
Andy

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://361987]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-16 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found