Home » Database » DB_DataObject » Bug #6320
Memory leak due to staticGet not calling free.
Details
| Submitted | 2005-12-22 00:57 UTC |
|---|---|
| From | shinyshez at yahoo dot co dot uk |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 5.0.4 |
| OS | Linux FC4 on x86_64 |
| Roadmaps | (Not assigned) |
Comments
[2005-12-22 00:57 UTC] shinyshez at yahoo dot co dot uk
Description:
------------
If staticGet returns 'false' then it is impossible for the
caller to free the global results memory used leading to
memory growth in long running scripts. If
staticGet returns an object then free() may be used on
that, but it isn't an ideal usage pattern.
The patch below calls free() on success and failure.
Test script:
---------------
--- /usr/share/pear.old/DB/DataObject.php 2005-08-18 09:52:37.000000000 +0100
+++ /usr/share/pear/DB/DataObject.php 2005-12-22 00:40:40.000000000 +0000
@@ -359,9 +359,11 @@
$_DB_DATAOBJECT['CACHE'][$lclass] = array();
}
if (!$obj->get($k,$v)) {
+ $obj->free();
DB_DataObject::raiseError("No Data return from get $k $v", DB_DATAOBJECT_ERROR_NODATA);
return false;
}
+ $obj->free();
$_DB_DATAOBJECT['CACHE'][$lclass][$key] = $obj;
return $_DB_DATAOBJECT['CACHE'][$lclass][$key];
}