ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-dev
php-dev
#50111 [Opn]: memory leak when stream_context_create is used
by datibbaw other posts by this author
Nov 7 2009 5:07PM messages near this date
#50111 [Opn->Fbk]: memory leak when stream_context_create is used | #50110 [NEW]: Static (File Scope) Variables
ID:               50111
 Updated by:       datibbaw@[...].net
 Reported By:      datibbaw@[...].net
 Status:           Open
 Bug Type:         Streams related
 Operating System: Linux
 PHP Version:      5.2.11
 New Comment:

Code to reproduce can be made simpler, since the problem seems to be
with stream_context_create():

$m0 = $m1 = $i = 0;
$c = null;
while ($i<5) {
    $m0 = memory_get_usage();
    $c = stream_context_create();
    $m1 = memory_get_usage();
    echo $m1-$m0,PHP_EOL;
    ++$i;
}


Previous Comments:
------------------------------------------------------------------------

[2009-11-07 09:26:05] datibbaw@[...].net

Description:
------------
When stream_context_create() is used in conjunction with
file_get_contents() or other stream related functions that accept a
context parameter, memory is being leaked.

Reproduce code:
---------------
for ($i=0;$i<5;++$i){
  $m0 = memory_get_usage();
  file_get_contents('http://www.google.com', false,
stream_context_create(array()));
  $m1 = memory_get_usage();
  echo $m1-$m0,PHP_EOL;
}

Expected result:
----------------
X (where X is the memory increase for the first iterator)
0
0
0
0


Actual result:
--------------
X (where X is the memory increase for the first iterator)
384 (or something similar)
420
420
480


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50111&edit=1
Thread:
Datibbaw@Php.Net
jani
datibbaw
datibbaw
jani
datibbaw
jani
datibbaw
jani
datibbaw
datibbaw
srinatar
datibbaw

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved