#26475 [Opn->Bgs]: Memory leaking with sockets
ID: 26475
Updated by: sniper@php.net
Reported By: ipa at beta dot lt
-Status: Open
+Status: Bogus
Bug Type: Sockets related
Operating System: Linux/FreeBSD
PHP Version: 4.3.4
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is by design. Memory used by resources is freed in the request
shutdown.
Previous Comments:
------------------------------------------------------------------------
[2003-11-30 15:56:55] ipa at beta dot lt
Description:
------------
Sockets' socket_read() left 8 bytes in memory.
Example configure:
'./configure' '--enable-versioning' '--enable-memory-limit'
'--with-layout=GNU' '--with-zlib-dir=/usr' '--disable-all'
'--with-regex=php' '--disable-cli' '--enable-ctype'
'--with-dom=/usr/local' '--with-gd' '--enable-gd-native-ttf'
'--enable-gd-jis-conv' '--with-freetype-dir=/usr/local'
'--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local'
'--with-xpm-dir=/usr/local' '--with-mysql=/usr/local'
'--enable-overload' '--with-pcre-regex=yes' '--enable-posix'
'--enable-session' '--enable-sockets' '--enable-tokenizer'
'--with-expat-dir=/usr/local' '--enable-xml' '--with-zlib=yes'
'--with-apxs2=/usr/local/sbin/apxs' '--with-imap=/usr/local'
'--with-imap-ssl=/usr/local' '--prefix=/usr/local'
'i386-portbld-freebsd4.8'
but reproducable on linux too.
Reproduce code:
---------------
function foo(){
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
$result = socket_connect ($socket, gethostbyname ('www.example.com'),
80);
$in = "HEAD / HTTP/1.0\r\n\r\n";
socket_write ($socket, $in, strlen ($in));
while ($out = socket_read ($socket, 2048)) { /* .. */ }
socket_close ($socket);
}
foo();
echo memory_get_usage() . "<br>";
foo();
echo memory_get_usage() . "<br>";
foo();
echo memory_get_usage() . "<br>";
Expected result:
----------------
xxxxx bytes.
xxxxx bytes.
xxxxx bytes.
Actual result:
--------------
xxxxx bytes.
xxxxx + 8 bytes.
xxxxx + 16 bytes.
...
xxxxx + (n * 8) bytes.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26475&edit=1
Thread (4 messages)