php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53098 stream_socket_client Memory Leak when using stream_context_create
Submitted: 2010-10-18 17:15 UTC Modified: 2010-10-18 22:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jayson dot cooke at ipeakmedia dot co dot uk Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 5.3SVN-2010-10-18 (snap) OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jayson dot cooke at ipeakmedia dot co dot uk
New email:
PHP Version: OS:

 

 [2010-10-18 17:15 UTC] jayson dot cooke at ipeakmedia dot co dot uk
Description:
------------
Using stream_socket_client on it's own works fine, but once using stream_context_create with it it creates a memory leak of 2kb each time which makes it unstable.

Test script:
---------------
<?php
  for ($i =0 ; $i <30 ; $i++)
  {
    $socket_options = array('socket' => array('bindto' => '127.0.0.1:0'));
    $socket_context = stream_context_create($socket_options);

    $fp=stream_socket_client('tcp://127.0.0.1:23', $error, $err, 5, STREAM_CLIENT_ASYNC_CONNECT|STREAM_CLIENT_CONNECT, $socket_context);

    unset($socket_context);
    unset($socket_options);
    unset ($fp);
    unset ($error);
    unset ($err);clea
    
    echo memory_get_usage()."\n";
  }
?>

Expected result:
----------------
648504
650400
650400
654000
650400
650400
650400
650400
650400
650400
650400
650400
650400
650400
650400
650400
650400
....

Actual result:
--------------
648504
650400
652200
654000
655864
657664
659464
661264
663064
664864
666664
668464
670392
672192
673992
675792
677592
679392
681192
682992
684792
686592
688392
690192
691992
693792
695592
697392
699448
701248

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-18 22:46 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-10-18 22:46 UTC] felipe@php.net
No mem leak detected in Valgrind.

btw, memory_get_usage(1) returns the same value.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC