[pve-devel] [PATCH manager] status/graphite: fix memory leak, avoid cyclic closure reference

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Nov 19 09:14:43 CET 2019


The data passed to this closure was never free'd, depending on the
count of VM/CTs one could get >1 MB of RSS (!) memory leaked per
statd status cycle update run...

We could also use Scalar::Util's weaken, to weak a copy of this
variable, but as a simple undef works lets do that with a comment..

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

what a bummer... We need to check all (recursive) closures and ensure they are
made undefined after they did their job..

 PVE/Status/Graphite.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/PVE/Status/Graphite.pm b/PVE/Status/Graphite.pm
index 14180aef..28fa65fd 100644
--- a/PVE/Status/Graphite.pm
+++ b/PVE/Status/Graphite.pm
@@ -141,6 +141,8 @@ sub assemble {
 	}
     };
     $assemble_graphite_data->($data, $path);
+
+    $assemble_graphite_data = undef; # avoid cyclic reference!
 }
 
 PVE::JSONSchema::register_format('graphite-path', \&pve_verify_graphite_path);
-- 
2.20.1





More information about the pve-devel mailing list