Skip to content

Static pointer memory leak fix #11

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

syedharoonalam
Copy link

getInstance () at rs/include/real_sense/real_sense_device_manager.h line 76, is defining static pointer variable 'instance' that is not getting reset/destroyed on stop, and caused issue when you need to call start/stop multiple times within same application.

getInstance () at rs/include/real_sense/real_sense_device_manager.h line 76, is defining static pointer variable 'instance' that is not getting reset/destroyed on stop, and caused issue when you need to call start/stop multiple times within same application.
@taketwo
Copy link
Owner

taketwo commented Feb 24, 2016

By resetting the RealSenseDeviceManager singleton instance you effectively destroy the underlying PXCSession. This will break any other grabbers existing within the app (in case you have multiple cameras running). So this does not look like a proper fix to me. Can you please provide more information about the specific problem you are facing?

@syedharoonalam
Copy link
Author

Sergey,

I am attaching a simple test file: real_sense_viewer.cpp for creating a Dll. For test, you can replace current file in your project with mine, in visual studio change: real_sense_viewer/Properties in Target extension and Configuration Type to .dll. This will create you a dll file.

Another test unity project is attached which simply calls Start_RS_LPM(), this will initiate real sense grabber and viewer, on pressing SHIFT key it will exit loop and call real sense to stop. I have now noticed that on stop only ~RealSenseViewer () and ~RealSenseGrabber () is called but not ~RealSenseDeviceManager () so static pointer variable didn't get released, on exiting unity it throws R6025-pure virtual function call, enclosed here is screen shot.

So as mentioned I tried calling getInstance().reset() in ~RealSenseGrabber () and it worked fine i.e all three destructors get called and I didnt faced error on exiting unity and previous data on calling Start_RS_LPM multiple times.

P.S memory do get free when exiting loop in executable and eventually exit app, there is no issue when running .exe

Regards,
Haroon
TEST.zip

@taketwo
Copy link
Owner

taketwo commented Feb 25, 2016

Haroon, thanks for the explanation. From what you wrote, it feels like a solution would be to provide a function that can be used to explicitly shut down the session. Unfortunately, I have a deadline early next week, so will be able to have a close look at the code you provided only in the second half. I will let you know about my findings.

@syedharoonalam
Copy link
Author

Great, thanks!

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