Edit report at https://bugs.php.net/bug.php?id=61371&edit=1
ID: 61371 Updated by: cataphr...@php.net Reported by: raiderz at gmail dot com Summary: stream_context_create() causes memory leaks on use streams_socket_create -Status: Verified +Status: Closed Type: Bug Package: Streams related Operating System: Linux PHP Version: Irrelevant Assigned To: cataphract Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2012-03-17 19:37:19] cataphr...@php.net Automatic comment from SVN on behalf of cataphract Revision: http://svn.php.net/viewvc/?view=revision&revision=324324 Log: - Fixed bug #61371 (resource leak). This bug had two parts, a long standing leak already fixed in trunk/5.3 and now merged onto 5.4 and a leak introduced in fixing bug #61115. This better fix for #61115 fixes the leak (the inhibition for deleting the context was too broad) and so prevents segfaults in new circumstances (where the inhibition was not broad enough). ------------------------------------------------------------------------ [2012-03-14 08:28:37] cataphr...@php.net This was fixed in trunk in r323478. If you unset also $errno and $errstr you have constant memory. PHP 5.4 still has the resource leak fixed in that revision because the fix has not been merged yet. PHP 5.3 seems to (also?) have a different and more serious leak. trunk: memory: 223kb memory: 223kb memory: 223kb memory: 223kb memory: 223kb 5.4: memory: 223kb memory: 290kb memory: 356kb memory: 424kb memory: 489kb 5.3: memory: 629kb memory: 711kb memory: 792kb memory: 875kb memory: 955kb I'll investigate later the problem in 5.3. ------------------------------------------------------------------------ [2012-03-13 15:34:33] raiderz at gmail dot com I update to 5.3.11-dev from snaps, bug already have in this version. New result: memory: 317kb memory: 338kb memory: 359kb memory: 380kb memory: 400kb ------------------------------------------------------------------------ [2012-03-13 14:32:22] cataphr...@php.net Please try using this snapshot: http://snaps.php.net/php5.3-latest.tar.gz For Windows: http://windows.php.net/snapshots/ ------------------------------------------------------------------------ [2012-03-13 10:29:25] raiderz at gmail dot com Description: ------------ stream_context_create() causes memory leaks on use width stream_socket_client Version PHP 5.3.6 Test script: --------------- for($test=1;$test<=5;$test++) { echo 'memory: '.round(memory_get_usage()/1024, 0)."kb\n"; for($i=0;$i<=100;$i++) { $context = stream_context_create(array()); $stream = stream_socket_client('udp://0.0.0.0:80', $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $context); fclose($stream); unset($context); unset($stream); } } Expected result: ---------------- memory: 615kb memory: 674kb memory: 732kb memory: 790kb memory: 847kb ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61371&edit=1