#25962 [Fbk->Opn]: php connect informix database caused memory leak

2003-10-26 Thread liu-shan at mediaring dot com
 ID:   25962
 User updated by:  liu-shan at mediaring dot com
 Reported By:  liu-shan at mediaring dot com
-Status:   Feedback
+Status:   Open
 Bug Type: Informix related
 Operating System: sun
 PHP Version:  4.3.2
 New Comment:

Hi, below is a sample, just for your reference.

I created a class call c_informix to fulfill connect to informix db and
insert data to it. I write a php program to call this class to insert
500,000 records into to test table, the program would auto died during
process. If you use some tools such as "top" to monitor this php
program, your could see the value of memory increased very fast. As
normal, after insert one record, the memory should release, but real
thing is the memory not release properly, once you continuous to insert
a large records, the momory goes to large value, system will auto kill
this process.

// c_informix.php ===
close();
break;
   }
}

exit;



function TestInsert($ifmx, $acc, $dbg)
{
   $result = true;

   $Liststmt = "insert into ls_test (lt_acct, lt_requester,
lt_reasoncode)";
   $Liststmt .= " values ('${acc}', 'm', 7000);";

   $ret = $ifmx->insert($Liststmt);
   if (!$ret)
   {
$fstr = "Error - " . $ifmx->errno() . ",  " . $ifmx->error() .
" - " . $Liststmt . " - test_db.php";
  WriteToLog($dbg, "daemon", "daemon", $fstr);
  $result = false;
  echo("error = " .  $fstr  . "\n\n");  
   }
  
   
   return $result;  
}

?>


// c_informix.php ===
class c_informix
{

// public: current error number and error text
var $ErrNo= "";
var $Error= "";

// private: connection parameters
var $Server= "";
var $Password= "";
var $User= "";
var $Conn= "";


function c_informix ($dbserver = "", $dbuser = "" , $dbpassword =
"")
{
  $this->Server= $dbserver;
  $this->User= $dbuser;
  $this->Password= $dbpassword;

 

  if (!empty($this->Server) && !empty($this->User) &&
!empty($this->Password))
  {
  $this->connect();
  }
}


 function connect()
 {
 $numtries = 50;
 $this->Conn = @ifx_connect($this->Server, $this->User,
$this->Password);
 while (!$this->Conn && $numtries)
 {
usleep(20);
$this->Conn = @ifx_connect($this->Server, $this->User,
$this->Password);
$numtries--;
 }

 if (!$this->Conn)
 {
$this->set_error();
return false;
 }

 return true;
 }
 

 function insert ($sql="")
 {
 $results = false;
 if (empty($sql))
 {
 $this->set_error("DB0002", "Empty command(s)");
 }
 else if (!eregi("^insert",$sql))
 {
 $this->set_error("DB0010", "Syntax
Error--".$sql."--");
 }
 else if (empty($this->Conn))
 {
 $this->set_error("DB0001", "Connection not
established");
 }
 else
 {
 $results = @ifx_query($sql,$this->Conn);
 if ($results)
 {
 $results = @ifx_affected_rows($results);
 }
 else
 {
 $results = false;
 $this->set_error();
 }
 }
 return $results;
 }


function set_error($errcode = "", $error = "")
{
if(!empty($errcode) && !empty($error))
{
$this->Error = $error;
$this->ErrNo = $errcode;
}
else
{
$this->Error = @ifx_errormsg();
$this->ErrNo = strtok(strstr(ifx_error(), "-"),
"]");
}

return true;
}


// public: returns the last error number
function errno()
{
return $this->ErrNo;
}


// public: returns the last error 

#25962 [NEW]: php connect informix database caused memory leak

2003-10-23 Thread liu-shan at mediaring dot com
From: liu-shan at mediaring dot com
Operating system: sun
PHP version:  4.3.2
PHP Bug Type: Informix related
Bug description:  php connect informix database caused memory leak

Description:

I'm PHP programer, I write web application using PHP connect to informix
database, informix CSDK version 2.7.1, no matter I SELECT, INSERT OR
UPDATE data to database, once program exit, but memory still that, cannot
release. it cause os memory leak, I have to reboot server frequently.
How can I resolve this problem


-- 
Edit bug report at http://bugs.php.net/?id=25962&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25962&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25962&r=trysnapshot5
Fixed in CVS:   http://bugs.php.net/fix.php?id=25962&r=fixedcvs
Fixed in release:   http://bugs.php.net/fix.php?id=25962&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25962&r=needtrace
Try newer version:  http://bugs.php.net/fix.php?id=25962&r=oldversion
Not developer issue:http://bugs.php.net/fix.php?id=25962&r=support
Expected behavior:  http://bugs.php.net/fix.php?id=25962&r=notwrong
Not enough info:http://bugs.php.net/fix.php?id=25962&r=notenoughinfo
Submitted twice:http://bugs.php.net/fix.php?id=25962&r=submittedtwice
register_globals:   http://bugs.php.net/fix.php?id=25962&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25962&r=php3
Daylight Savings:   http://bugs.php.net/fix.php?id=25962&r=dst
IIS Stability:  http://bugs.php.net/fix.php?id=25962&r=isapi
Install GNU Sed:http://bugs.php.net/fix.php?id=25962&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25962&r=float