Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix leak of CyCoinModel CppSelf #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bkurtz
Copy link

@bkurtz bkurtz commented Apr 18, 2024

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

@CLAassistant
Copy link

CLAassistant commented Apr 18, 2024

CLA assistant check
All committers have signed the CLA.

@bkurtz bkurtz force-pushed the fix-leak-cycoinmodel branch from b663405 to 3736345 Compare April 18, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants