memory release with fetchall_arrayref

R

rkusenet

Perl 5.6.1 on Linux.

My colleague noticed this in Informix and I noticed it in Sybase.

Here is the relevant code. I am writing this code off my hat

sub memory_problem {
my $sql = "SELECT * FROM SOME BIG TABLE" ;
my $sth = $dbh->prepare($sql);
$sth->execute ;
my $rowdata = $sth->fetchall_arrayref ;
}

Now when this subroutine gets completed, we should expect
all memory associated with variable $rowdata to be released, right?
When I tested the program against Sybase, I saw the memory size
of the program grow from 350K to 18M and then it remained at that,
even when the subroutine was completed.
The memory was never released until the program terminated.

I tested this on Solaris 5.6 against Informix 9.21 by a perl 5.6.0
program and the behaviour is same.

This behaviour is not what I understand of perl garbage collection.
 
X

xhoster

rkusenet said:
Perl 5.6.1 on Linux.
....

Now when this subroutine gets completed, we should expect
all memory associated with variable $rowdata to be released, right?

No. This is a FAQ

perldoc -q shrinks

Xho
 
S

Superboer

i miss
my $sth = $dbh->prepare($sql);
$sth->execute ;
$sth->free
sorry wild guess am not into this code; however if you prepare a stmt
you should free it somewhere..
in informix check onstat -g ses <sid> if ralloc is big then it's likely
that you forget to free
prepped stmt's
one could run onstat -g stm <sid> if version > 9.2
to see which statements are all still there.


Superboer.



rkusenet schreef:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top