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

MerginProject may not get cleaned up properly #149

Open
wonder-sk opened this issue Oct 18, 2022 · 0 comments
Open

MerginProject may not get cleaned up properly #149

wonder-sk opened this issue Oct 18, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@wonder-sk
Copy link
Contributor

When MerginProject is created, it creates geodiff object and assigns an internal logger to geodiff. This creates a cyclic reference (pygeodiff refs MerginProject, and MerginProject refs pygeodiff) that may keep resources held, which may be a problem if MerginProject object is created many times. See also fix for this in db-sync: MerginMaps/db-sync#79

Also somehow related: MerginMaps/geodiff#190

Code snippet to replicate the cleanup issue:

import pygeodiff

class MerginProjectX:

    def __init__(self, directory):

        def _logger_callback(level, text_bytes):
            self.x()   # not a real function, but refs this object...

        self.geodiff = pygeodiff.GeoDiff()
        self.geodiff.set_logger_callback(_logger_callback)

# this will keep consuming more and more resources
for i in range(50000):
    print(i)
    mp = MerginProjectX("x")
    #mp.geodiff = None    # this helps to break ref cycle
    time.sleep(0.005)
@wonder-sk wonder-sk added the bug Something isn't working label Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant