|  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: -
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
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.
Block user comment
Status: Assign to:
Bug Type:
From: jnelson at archive dot org
New email:
PHP Version: OS:


 [2016-02-16 21:45 UTC] jnelson at archive dot org
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:

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().


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Feb 27 10:01:24 2021 UTC