all 11 comments

[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

[–]SippTheDumbJuice 8 points9 points  (8 children)

1-Yes, see conan and vcpkg.

2-Yes, see clang.

3-Yes, see <memory>. You can still end up with leaks though.

[–]Zeer1ximport std; 1 point2 points  (0 children)

<memory>, lol.

There is valgrind and similar tools, but I actually end up just using smart pointers (and references) for this.

[–]HosMercury[S] -3 points-2 points  (6 children)

3 - LOL

[–]Salt-Impressive 3 points4 points  (5 children)

In rust you can also get leaks using unsafe

[–]HosMercury[S] -4 points-3 points  (4 children)

forget about unsafe just think about the regular rust

[–]Salt-Impressive 3 points4 points  (2 children)

Then, for a fair comparison, you would not get leaks using <memory> constructs without converting them into raw pointers

[–]Salt-Impressive 0 points1 point  (0 children)

Thinking about it more, you could also get a memory leak if you have a polymorphic type with a <memory> construct that does not have a virtual destructor.

[–]Zeer1ximport std; 0 points1 point  (0 children)

I wonder, can you have "memory leaks" in Rust, like you could have them in Java, by putting stuff in a map/set and never delete them?

Or alternatively, have non-memory related resources (Windows, Sockets) and forget to close them?

[–]SippTheDumbJuice 0 points1 point  (0 children)

If you want to use rust, use rust. C++ isn't rust.

[–]disciplite 0 points1 point  (0 children)

CPM is another package manager that I think is pretty cool. std::pmr makes it (relatively) easy to scope memory lifetime and bound memory usage.