auto currentState = globjects::State::currentState();
[...]
currentState->apply();
currentState->destroy(); // Tried with and without, same leak
got this:
=32073== 280 bytes in 5 blocks are definitely lost in loss record 76 of 124
==32073== at 0x4C2A105: operator new(unsigned long) (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==32073== by 0x61B5DC: globjects::StateSetting::StateSetting<unsigned int>(void (*)(unsigned int), unsigned int) (in ~/Demo/Stitcher/build/Stitcher)
==32073== by 0x619E85: globjects::AbstractState::primitiveRestartIndex(unsigned int) (in ~/Demo/Stitcher/build/Stitcher)
==32073== by 0x62A6C9: globjects::State::currentState() (in ~/Demo/Stitcher/build/Stitcher)
==32073== by 0x5B81B1: Stitcher::Application::Impl::fetchSources() (Application.cpp:275)
==32073== by 0x5B2C52: Stitcher::Application::runLoop() (Application.cpp:415)
==32073== by 0x5AEBD3: main (main.cpp:114)
==32073==
I'm doing this for each frame, and it's a pain.
As a side note, all the sample code on the main page says use the auto var = new XXX pattern without saying why and what is supposed to be used inside a class member. I think you should emphasize to use ref_ptr<T> instead, since the former leaks (auto is mapped to XXX * not ref_ptr<XXX> in that case)
Or I'm unsure how to use it. I've this code:
got this:
I'm doing this for each frame, and it's a pain.
As a side note, all the sample code on the main page says use the
auto var = new XXX
pattern without saying why and what is supposed to be used inside a class member. I think you should emphasize to useref_ptr<T>
instead, since the former leaks (auto
is mapped toXXX *
notref_ptr<XXX>
in that case)