I have tested a new version of Win32::OLE that allows the following program to work ("work"=pass all module tests and not leak memory when running while monitored using the Task Mangler). Any thoughts about how to get this reviewed and maybe into the CPAN release?
# OLE Variant memory test
use strict;
use Win32::OLE::Variant;
for my $i ( 0 .. 10000 ) # Do many times so we have a lot of memory al
+locations
{
my $v = Win32::OLE::Variant->new(VT_ARRAY|VT_BSTR, [1,1000]);
$v->Put(1, "foo");
# Do something here to make $vr a separate variant that points to th
+e data in $v
# my $vr = Win32::OLE::Variant->new(VT_ARRAY|VT_BSTR|VT_BYREF, $v);
+<-- LEAK in ver 0.1712
# With version 0.1714, we never make a Variant with VT_BYREF explici
+tly.
# Instead we make a variant without the VT_BYREF flag, then call B
+yRef()
# on it to return a reference.
my $vr = $v->ByRef();
DoStuff( $vr ); # modify and see if $v has changed
if ( $i == 0 )
{
# next line should print: 0x2008, bar 1; 0x6008, bar 1
printf "0x%04x, %s; 0x%04x, %s\n", $v->_RefType(), $v->Get(1), $
+vr->_RefType(), $vr->Get(1);
printf "0x%04x, %s; 0x%04x, %s\n", $v->_RefType(), $v->Get(2), $
+vr->_RefType(), $vr->Get(2);
}
undef $v;
} # while this loop is running, check the Task Mangler for memory usa
+ge
print STDERR "Done.\n";
sub DoStuff
{
my $refVar = shift;
for my $i ( 1 .. 1000 )
{
$refVar->Put($i, "bar $i");
}
}
|