memory release with fetchall_arrayref

Discussion in 'Perl Misc' started by rkusenet, Apr 13, 2006.

  1. rkusenet

    rkusenet Guest

    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.
    rkusenet, Apr 13, 2006
    #1
    1. Advertising

  2. rkusenet

    Guest

    "rkusenet" <> wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
    , Apr 13, 2006
    #2
    1. Advertising

  3. rkusenet

    Superboer Guest

    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:

    > 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.
    Superboer, Apr 13, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mahesh Prasad
    Replies:
    1
    Views:
    690
    Tom Wells
    Feb 22, 2004
  2. John Goche
    Replies:
    1
    Views:
    7,442
    John Goche
    Dec 17, 2005
  3. Oliver G

    fetchall_arrayref into bind_param_array

    Oliver G, Nov 12, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    433
    Oliver G
    Nov 13, 2003
  4. Syl
    Replies:
    5
    Views:
    173
  5. Filippo
    Replies:
    2
    Views:
    111
    Filippo
    Feb 19, 2007
Loading...

Share This Page