Skip to content

Conversation

@eric-wieser
Copy link
Contributor

No description provided.

@eric-wieser
Copy link
Contributor Author

This should fix a memory leak where a new thread is allocated every cycle

sl::zed::Camera *zed;
std::unique_ptr<sl::zed::Camera> zed;
if (argc == 2) {
zed = new sl::zed::Camera(argv[1]); // Argument "svo_file" in launch file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line doesn't pass the compilation process.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What error does it give? I'm afraid I don't have access to a suitable compiler on my platform, and access to my embedded target is intermittent. Thanks for testing this for me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 21:40pm for me, so I don't have the error log with me, but I'll tell you tomorrow! However, I'm not used to std::unique_ptr, but don't we need to use std::move() to set the pointed object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks! I won't be able to try things myself till then anyway.

I misread which line your comment was on. I think I see the fix.

`operator=` only works when the value is a `std::unique_ptr`. In C++ 14, this would be fixed by writing:

    zed.reset(new sl::zed::Camera(static_cast<sl::zed::ZEDResolution_mode> (resolution), rate));

as 

    zed = std::make_unique<sl::zed::Camera>(static_cast<sl::zed::ZEDResolution_mode> (resolution), rate);
adujardin added a commit that referenced this pull request Mar 3, 2016
@adujardin adujardin merged commit def003f into stereolabs:master Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants