|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Sybperl memory leak
Date: Feb 11 1999 6:43PM
>>>>> "Steve" == Wechsler, Steven M writes:
Steve> I ran this program on NT 4.0 running ActivePerl 5.00502 and the
Steve> latest version of Sybperl available from the Activestate web
Steve> site.
Steve> Each iteration of the loop caused 64K more memory to be
Steve> allocated. Michael, your web site mentions a 300 byte memory
Steve> leak; any idea how 300 bytes becomes 64K?
Actually I re-did the test here, and I get a 2.9k leak per iteration
(not good, but better than 64k). This is on Solaris 7, OC 11.1.1. I
don't know how much of that is in the Sybase code, and how much is in
the perl code.
Right now I don't really have the time nor the tools to chase this
down. If someone with purify or some similar tools wants to give it a
go I'd be more than happy to hear from you.
In the meantime (at least on Unix systems) your script could be
re-written like this to avoid excessive bloating:
use Sybase::DBlib;
for(my $count = 1;; $count++) {
sleep(10);
my $dbh = new Sybase::DBlib $user, $pwd, $server;
warn "$server is down or unreachable\n" unless $dbh;
if(($count % 100) == 0) {
exec "$0 @ARGV";
}
}
__END__
By using the "my $dbh" in the loop the dbclose() call will be done
automatically.
By putting the sleep() first the connection doesn't stay open any
longer than necessary.
The exec() call re-exec's the script every 100 calls, which should
keep the total memory usage in check (I don't know if exec() works on
Win32 platforms, though).
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
|