Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: jjgmeinder at dodge dot ra dot rockwell dot com
Subject: out of memory
Date: Mar 31 1999 9:30PM

I am attempting to do a cross database join using 2 connections in my perl
script.  I am running out of memory IF I do the inner while loop - that is the
lookup to the 2nd database.  If I just comment out the inner while loop I do not
leak memory.

HPUX 11.0, perl 5.004_04, sybperl 2.09_05

I use glance to watch the memory usage increasing for the process.  At 512meg it
blows up with "out of memory" message.  Again, if I comment out the inner while
loop (the second connection) my memory usage stays constant until all 4million
rows are returned.

Any ideas?  Do I need to setup the 2nd connection differently?

john g.

here is my gutted script:
$dbh = Sybase::CTlib->ct_connect($uid, $pwd, $srv);
$dbh->ct_sql("use $db");      #connect to a database

$dbh_stg = Sybase::CTlib->ct_connect($stguid, $stgpwd, $stgsrv);
$dbh_stg->ct_sql("use $stgdb");          #connect to a database


while(($rc = $dbh->ct_results($restype)) == CS_SUCCEED) {
   next if(!$dbh->ct_fetchable($restype));

   while(%dat = $dbh->ct_fetch(1)) {

      #get the matching row
      select dw_time_key from dimkeys_time
        where date_key="$dat{invoice_dt}"
      ### execute the sql
      while(($rc_stg = $dbh_stg->ct_results($restype_stg)) == CS_SUCCEED) {
     next if(!$dbh_stg->ct_fetchable($restype_stg));
         %dat_stg = $dbh_stg->ct_fetch(1);
         $dw_time_key=$dat_stg{dw_time_key};  #save the dw time key
         #we only want the first row so cancel the rest

  } #end while %dat=$dbh->ct_fetch

} #end  while $rc = $dbh->ct_results