#!/usr/bin/perl -w

use strict;
use Mail::Box::Mbox;
use Devel::Leak;

use lib '../lib';

my $TMPDIR = "/var/tmp";
my $mbox = "./smallmbox";
# Set this higher and see the object count (and memory usage) go up up up!
my $RUNS = 1;

my $leakhandle;
my $leakcount = Devel::Leak::NoteSV($leakhandle);

# Open the mailbox, lots of times
my $count = 0;
print STDERR "Opening $mbox $RUNS times, cloning contents ,,";
while ($count < $RUNS) {

    my $large2 = Mail::Box::Mbox->new(folder => $mbox,
 			      access => 'r',
 			      write => 'NEVER',
 			      );
delete $large2->{MBF_create_options};
delete $large2->{MB_locker}{MBL_folder};
delete $large2->{MBF_parser};

use Data::Dumper;
print Dumper $large2;

    $count++;

    $large2->close;
}
print STDERR ",, done\n";
my $newleakcount = Devel::Leak::CheckSV($leakhandle);
print STDERR "Had $leakcount objects, now have $newleakcount\n";

exit 0;
