From:
Operating system: Linux
PHP version: 5.3.2
Package: Session related
Bug Type: Bug
Bug description:session_start / session_write_close memory leak
Description:
------------
session_start() and session_write_close() don't free unused memory. When
they are called multiple times, the memory usage reported by
memory_get_usage() constantly grows.
The session data is stored in files, ini settings are default.
# php -v
PHP 5.2.9 (cli) (built: Sep 1 2009 11:43:38)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
with Suhosin v0.9.31, Copyright (c) 2007-2010, by SektionEins GmbH
Test script:
---------------
session_start();
$_SESSION["foo"] = str_repeat("bar", 5000);
session_write_close();
$memory_before = round(memory_get_usage() / 1024, 2) . "KB";
for ($i=0; $i<1000; $i++)
{
session_start();
session_write_close();
}
$memory_after = round(memory_get_usage() / 1024, 2) . "KB";
echo "Before: " . $memory_before . "\n";
echo "After: " . $memory_after;
Expected result:
----------------
Before: 88.34KB
After: 88.34KB
(or something small amount)
Actual result:
--------------
Before: 88.34KB
After: 19906.61K
--
Edit bug report at http://bugs.php.net/bug.php?id=52109&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52109&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52109&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52109&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52109&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52109&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52109&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52109&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52109&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52109&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52109&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52109&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52109&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52109&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52109&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52109&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52109&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52109&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52109&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52109&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52109&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52109&r=mysqlcfg