#
# This software is Copyright 2005 by Elsevier Inc.  You may use it
# under the terms of the license at http://perl.plover.com/hop/LICENSE.txt .
#



###
### iterator-memtrack.pl
###

## Chapter 4 section 6.3.3

my %creator;

sub Iterator (&) { 
  my $creator = (caller)[3];
  $extant{$creator}++;
  bless $_[0] => 'Iter';
  $creator{$_[0]} = $creator;
  print STDERR "+ $creator $extant{$creator}\n";
  return $_[0];
}
sub Iter::DESTROY {
  my $iterator = shift;
  my $creator = $creator{$iterator};
  $extant{$creator}--;
  print STDERR "- $creator ($extant{$creator})\n";
}
