CyLP icon indicating copy to clipboard operation
CyLP copied to clipboard

Fix leak of CyCoinModel CppSelf

Open bkurtz opened this issue 10 months ago • 1 comments

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()}")

mem_usage

bkurtz avatar Apr 18 '24 17:04 bkurtz

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 18 '24 18:04 CLAassistant