Skip to content

SIFT memory leak #169

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

Open
tomerdmnt opened this issue Dec 24, 2017 · 1 comment
Open

SIFT memory leak #169

tomerdmnt opened this issue Dec 24, 2017 · 1 comment

Comments

@tomerdmnt
Copy link
Contributor

It seems that the SIFT detection leaks memory. Here is the example script I am running.

import arrayfire as af
import time

while True:
    im = af.load_image('image.jpg')
    feats, desc = af.vision.sift(im)

    af.device.device_gc()
    af.print_mem_info()
    time.sleep(1)

I solved part of the leaks in #168. Apparently the features destructor wasn't called, and af_release_features needed to be called explicitly from python.

With this fix the ORB feature detection works without leaks, but SIFT and GLOH still do.

Running pretty much the same methods in C works without a memory leak. So I think there might be another destructor that ought to be called explicitly, just like af_release_features, but I could not figure out where the leak was originated from.

@tomerdmnt
Copy link
Contributor Author

Somewhat related to this, after getting an array from a feature, say xpos = feature.get_xpos(), there is a double free bug, because the array is cleaned when af_release_features is called in the feature's __del__ and also in the array __del__ method.

Right now, I work around it by setting xpos.arr.value = 0 before the destructors are called.

It's possible to fix this by getting the feature to save a reference to all its arrays, and cleaning them properly. Do you think is a reasonable fix? I'd be happy to open a pull request for it.

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

No branches or pull requests

1 participant