Project

General

Profile

Actions

Bug #15459

closed

Memory leak affecting ``lcdproc_client.php``, eventually hits PHP memory limit and crashes

Added by Jim Pingle 29 days ago. Updated 25 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
LCDProc
Target version:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Affected Version:
Affected Plus Version:
Affected Architecture:

Description

There is a memory leak affecting lcdproc_client.php leading it to eventually running out of RAM and dying with a PHP error:

PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 8192 bytes) in /usr/local/pkg/lcdproc_client.php on line 856

The actual line varies from run to run.

Looking over the way the code is structured it has several potential issues where memory could be leaking though even after reworking the code and eliminating all of the issues I could identify there is still a slow leak.

A few things I was able to eliminate and identify:

  • It is not from reading/writing to the LCD socket or any file handles
  • It is not from keeping the LCD socket open
  • Forcing garbage collection doesn't help
  • Seems to leak 3808 bytes per loop even with no screens enabled.
  • Certain functions leak more than others. In particular:
    • With the Interfaces screen enabled the total amount leaked is 5600
    • With the output LEDs disabled, amount leaked goes down to 1904

Some of the leak appears to be in base, not the package, coming from get_interface_info(), specifically calls inside that:

  • get_interface_addresses() leaks about 2000 bytes
  • get_interface_ipv6() leaks about 800 bytes
  • get_interface_subnetv6() leaks about 800 bytes

Still investigating...

Actions

Also available in: Atom PDF