#29560 [Fbk->Opn]: Listening on non-blocking socket leaks memory
| From: | info at tphnet dot com | Date: | Mon, 09 Aug 2004 00:04:16 +0000 |
| Subject: | #29560 [Fbk->Opn]: Listening on non-blocking socket leaks memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64279@lists.php.net to get a copy of this message | ||
ID: 29560
User updated by: info at tphnet dot com
Reported By: info at tphnet dot com
-Status: Feedback
+Status: Open
Bug Type: Sockets related
Operating System: Windows XP SP1
PHP Version: 5.0.0
New Comment:
Tested using:
PHP 5.1.0-dev (cli) (built: Aug 8 2004 16:31:06)
The memory leak is still there, as described in my previous reply.
Previous Comments:
------------------------------------------------------------------------
[2004-08-08 01:47:37] wez@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Try a snapshot, as a couple of peername related bugs were fixed
recently.
------------------------------------------------------------------------
[2004-08-07 19:23:22] info at tphnet dot com
I can confirm the memory leak that I described in my original bug
report has disappeard.
BUT, I found a new memory leak inside the stream_socket_accept()
function. If you set the third argument peername to a variable, the
function will leak a little bit of memory everytime it's called. The
effect is the same as with the original bug in socket_accpet().
Just modify the example in my previous reply by changing
$new_connection = @stream_socket_accept($socket, 0);
into
$new_connection = @stream_socket_accept($socket, 0, $peer);
and see what happens. In my case (Windows XP, php 5.0.0 CLI) the script
starts leaking memory.
------------------------------------------------------------------------
[2004-08-07 17:55:35] info at tphnet dot com
I changed to code to the following:
<?php
$socket = stream_socket_server('tcp://localhost:1234', $errno,
$errstr);
stream_set_blocking($socket, 0);
while(true){
$new_connection = @stream_socket_accept($socket, 0);
unset($new_connection);}
?>
There is no memory leak anymore and everything is working as expected.
It appears the problem is solved.
------------------------------------------------------------------------
[2004-08-07 15:07:44] wez@php.net
Urgh, ignore that (clicked wrong link).
The sockets extension is unmaintained.
Try stream_socket_create() and fiends instead.
------------------------------------------------------------------------
[2004-08-07 14:50:11] wez@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/29560
--
Edit this bug report at http://bugs.php.net/?id=29560&edit=1