On Apr 18, [EMAIL PROTECTED] wrote:
> On Mon, Apr 17, 2000 at 11:12:24AM -0700, Perrin Harkins wrote:
> > [EMAIL PROTECTED] wrote:
> > > Now with modperl the Perl garbage collector is
> > > NEVER used.  Because the reference count of those variables is never
> > > decremented... it's because it's all in the registry, and it's hard to
> > > tell... hmm... what should I throw away, and what should I keep? ;-).
> > 
> > What I know about Perl internals could fit on the head of a pin, but
> > this strikes me as a very odd statement.  If the garbage collector is
> > never used, why do my lexical variables go out of scope and get
> > destroyed?  There are mod_perl packages like Apache::Session that
> > absolutely depend on garbage collection of lexical variables to work. 
> > Are you saying that destroying the variables and actually reclaiming the
> > memory are separate, and only the first is happening?
> 
> Go out of scope, yes.  Destroyed, no.  Want to test?  No problem.  Do
> the following in a perl script.

I think you're mistaken. Try the following:

package My::Test;

sub new {
  return bless {}, shift;
}
sub DESTROY {
  warn "destroyed";
}
sub test {
  my $object = new My::Test;
  print ref $object, "\n";
  # object will get destroyed when it goes out of scope (now)
}

for (1..10) {
  warn "t $_\n";
  test();
}

__END__

Your second example doesn't do what I think you were expecting.

Jim

Reply via email to