in reply to Re: better way to cleanup a package?
in thread better way to cleanup a package?

The problem with this way is the sub packages, and you don't clean the memory very well!
Before to do a
undef *{"scalarvar"}
you need to do
undef ${"scalarvar"}
or the memory are not cleaned very well!

And a package are only cleaned with:
undef *{"packname::"}
not with:
undef *{"packname"}
But you need to clean the variables and functions inside before!

I made some tests of the reuse of 100 times of a package, with a randome variable with 50Mb, and it don't use more than 60Mb in the memory. But if I only do a undef *{"foovar"}, without undef ${"foovar"} first, the process use 100Mb!

Graciliano M. P.
"The creativity is the expression of the liberty".

  • Comment on Re: Re: better way to cleanup a package?

Replies are listed 'Best First'.
Re: Re: Re: better way to cleanup a package?
by shotgunefx (Parson) on Dec 04, 2002 at 01:50 UTC
    My tests show no difference in memory usage between undef *{"scalarvar"} and first undef ${"scalarvar"}. Perhaps you had a memory leak? My understanding is that Perl won't return the memory to the OS, just make it available to itself when freed. (Until the process terminates of course.)

    As far as not clearing out sub packages, I think of that as a feature. It would be rare enough to want to clear out a package in this manner, so my feeling is that if you would want clear out sub-packages (which may or may not have a relationship to the package being deleted) you should be explicit.

    -Lee

    "To be civilized is to deny one's nature."