The lvm C library requires that you close/re-open for long
running processes to reclaim memory.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
targetd/block.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/targetd/block.py b/targetd/block.py
index da78872..35c27ab 100644
--- a/targetd/block.py
+++ b/targetd/block.py
@@ -54,13 +54,24 @@ def vgopen(pool_name):
"""
Helper function to check/close vg for us.
"""
+ global lib_calls
pool_check(pool_name)
with contextlib.closing(lvm.vgOpen(pool_name, "w")) as vg:
yield vg
+ #Clean library periodically
+ lib_calls += 1
+ if lib_calls > 50:
+ try:
+ #May not be present if using older library
+ lvm.gc()
+ except AttributeError:
+ pass
+ lib_calls = 0
pools = []
target_name = None
+lib_calls = 0
#
--
1.8.2.1