CyLP
CyLP copied to clipboard
Fix leak of CyCoinModel CppSelf
CyCoinModel allocates a C++ object CppSelf
and fails to deallocate it.
A simple test script allocating CyCoinModel
objects in a loop and deleting them shows significant memory leaked prior to this patch, and negligible memory leaked after (run in a python3.9 docker image):
import gc
import resource
import cylp.cy
def maxrss() -> int:
return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
print("runs\tmaxrss")
for i in range(10000):
model = cylp.cy.CyCoinModel()
del model
gc.collect()
if i % 100 == 0:
print(f"{i}\t{maxrss()}")