[comp.lang.perl] perl usage of memory? a long lasting perl server

stef@zweig.sun (Stephane Payrard) (05/31/90)

Suppose I have a perl script living forever (implementing some kind of
server with a growing context)
which defines variables or/and arrays and later undefines some of them.
Is perl sophisticated enough to reuse the memory left by the no more used
`undefined variables'?


If not, is there a scheme to exec a new instance of the script
and feeding it with the context of  its parent? So the son can
resume the task where its dad left it.

The scheme I imagine is that the father can exec a son and feed it
(thru a pipe) with perl code interpreted by its son which sets the
context of the son to be identical to the father. A modified version
of dumpvar could do the trick It would obviate the fact that a Unix
process can only grow. Once a while the process interpreting the perl
script will disappear to leave its newly execed son to continue the
task.

Is it science fiction?

Another question. Is there any recovery scheme in perl to handle the inability
of allocating more memory.

Larry?


stef


--
Stephane Payrard -- stef@sun.com -- (415) 336 3726
Sun Microsystems -- 2550 Garcia Avenue --  M/S 10-09 -- Mountain View  CA 94043
room number: 138
                     
                     

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (06/07/90)

In article <STEF.90May31004958@zweig.sun> stef@zweig.sun (Stephane Payrard) writes:
: 
: Suppose I have a perl script living forever (implementing some kind of
: server with a growing context)
: which defines variables or/and arrays and later undefines some of them.
: Is perl sophisticated enough to reuse the memory left by the no more used
: `undefined variables'?

It's supposed to be.  If it isn't, I'd consider it a bug.

: If not, is there a scheme to exec a new instance of the script
: and feeding it with the context of  its parent? So the son can
: resume the task where its dad left it.
: 
: The scheme I imagine is that the father can exec a son and feed it
: (thru a pipe) with perl code interpreted by its son which sets the
: context of the son to be identical to the father. A modified version
: of dumpvar could do the trick It would obviate the fact that a Unix
: process can only grow. Once a while the process interpreting the perl
: script will disappear to leave its newly execed son to continue the
: task.
: 
: Is it science fiction?

No, you could do that as a workaround to any problem.  But I'd rather just
fix the problem, if you find any.

: Another question. Is there any recovery scheme in perl to handle the inability
: of allocating more memory.

Not really.  You might just be able to trap the fatal error in an eval
and do something with it, but in general Perl is pretty good about freeing
memory, so it wouldn't get you much.

Larry