ID:               26475
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ipa at beta dot lt
 Status:           Bogus
 Bug Type:         Sockets related
 Operating System: Linux/FreeBSD
 PHP Version:      4.3.4
 New Comment:

Nope, it doesn't do that. Sniper was slightly wrong. If you do a
socket_close it should clean up the resource, and it also does that.
What you see here is most likely some of the performance tweaks in PHP.
If you keep doing this in a loop you'll see that there is an upper
limit on this.


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

[2003-12-01 03:26:41] ipa at beta dot lt

Hm. as i understand it's not possible to write long-running socket
server ? because after ~1 mln recieved connections it'll rich all 8 MB
memory limit??

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

[2003-12-01 02:13:05] [EMAIL PROTECTED]

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.


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

[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

Reply via email to