-
Notifications
You must be signed in to change notification settings - Fork 393
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
libindiclient leaks last blob on driver restart #1528
Comments
It should be clear. Not sure what @pawel-soja has intended exactly with this? Can you uncomment and test it out? Maybe because the BLOB could be shared with the client still so freeing the buffer would cause issues in the client at this stage... but we are responsible for freeing any memory we allocate. |
Ok looks like @pawel-soja is busy. Did you try uncommenting the free and check for any possible regressions? |
@pawel-soja was this issue fixed in your latest PR? |
@knro sure i will check it out, but after i finish rework in CMakeLists. |
@pawel-soja Any confirmation on whether this issue is resolved? |
Hey, I analyzed the problem. The indi/libs/indidevice/basedevice.cpp Lines 796 to 800 in fe39e52
So, as I mentioned, I left the Property behavior unchanged so as not to free someone's memory. There are 2 choices, either fix the |
There is also an option to add the // A
{
INDI::PropertyBlob blob{1};
blob.setBlobDeleter([](void *data)
{
free(data); // correct for malloc
});
blob[0].setBlob(malloc(128));
}
// B
{
INDI::PropertyBlob blob{1};
blob.setBlobDeleter([](void *data)
{
delete[] reinterpret_cast<char*>(data); // correct for new operator[]
});
blob[0].setBlob(new char[128]);
} |
I like this deleter option as it gives more freedom on how should be cleared on property destruction. |
This issue has been inactive for 60 days and is being marked as stale. |
This issue has been closed due to inactivity. |
Upon removal of devices or property, blob data are not freed. As a result, a memory leak of blob will occurs when a driver that has received blob is restarted:
Repeating 5&6 will make dummy-streamer program memory size. You can use bigger frame size to make the problem more obvious. Alternatively, running dummy-streamer with valgrind will report the following leak:
My though: blob data freeing is commented out in indipropertyview.h, so there is simply no free on removal. I am not sure the impact of activating it back however.
The text was updated successfully, but these errors were encountered: