php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71613 nonblocking UDP stream_socket_recvfrom() memory leak
Submitted: 2016-02-16 21:45 UTC Modified: -
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: jnelson at archive dot org Assigned:
Status: Open Package: Performance problem
PHP Version: 5.5.32 OS: Ubuntu
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-02-16 21:45 UTC] jnelson at archive dot org
Description:
------------
While coding a UDP server with stream_socket_recvfrom(), I found a memory leak when (a) the stream is set to nonblocking mode, (b) the optional $address reference is passed, and (c) no data is ready.  If $address is not passed, there is no leak.

It appears the leak only occurs if there's some traffic on the socket, meaning that this won't happen simply listening on a quiet port.  I'm including two scripts, client.php and server.php, which must be run together for the server script to exhibit the leak.

Test script:
---------------
client.php: http://archive.org/~jnelson/client.php.txt
server.php: http://archive.org/~jnelson/server.php.txt

Expected result:
----------------
Expect memory usage to remain roughly the same for the duration of execution.

Actual result:
--------------
server.php's memory usage gradually increases over time, but only if $address is requested in the call to stream_socket_recvfrom().

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Nov 15 13:01:35 2019 UTC