From 8cdca14b692a052bac143d165dfc0a15a3f11e3e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 21 Oct 2019 22:54:03 +0200 Subject: Fix Python memory leaks --- bindings/python/lilv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bindings') diff --git a/bindings/python/lilv.py b/bindings/python/lilv.py index cc4101e..47179c5 100644 --- a/bindings/python/lilv.py +++ b/bindings/python/lilv.py @@ -1342,11 +1342,13 @@ class World(Structure): return subject.get_symbol() uri = _as_uri(subject) + ret = "" if uri is not None: node = c.world_get_symbol(self.world, uri.node) - return c.node_as_string(node).decode("ascii") if node else "" + ret = c.node_as_string(node).decode("ascii") if node else "" + c.node_free(node) - return "" + return ret def new_uri(self, uri): """Create a new URI node.""" @@ -1400,6 +1402,10 @@ class Instance(Structure): self.rate = rate self.instance = c.plugin_instantiate(plugin.plugin, rate, features) + def __del__(self): + if hasattr(self, "instance"): + c.instance_free(self.instance[0]) + def get_uri(self): """Get the URI of the plugin which `instance` is an instance of. -- cgit v1.2.1