Hi,
Is it possible that a memory leak was occurring because of a missing virtual destructor?
virtual ~ClassName() {}
If the default behaviour of the virtual destructor prevents the leak, why didn't cppcheck warn about it?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"It's not a new/delete - the ClassName code uses smart pointers
I suspected we were passing around a std::shared_ptr<namespace::classname> </namespace::classname>
Which actually pointed to a derived builder and the lack of virtual destructor on ClassName meant the derived destructor wasn't called when the shared pointer went out of scope"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Is it possible that a memory leak was occurring because of a missing virtual destructor?
virtual ~ClassName() {}
If the default behaviour of the virtual destructor prevents the leak, why didn't cppcheck warn about it?
Thanks.
could you show a minimal example code where there is a leak and we do not warn?
Not sure. Does this help?
"It's not a new/delete - the ClassName code uses smart pointers
I suspected we were passing around a std::shared_ptr<namespace::classname> </namespace::classname>
Which actually pointed to a derived builder and the lack of virtual destructor on ClassName meant the derived destructor wasn't called when the shared pointer went out of scope"
Is this enough or must I really provide an example?
I managed to put together an example. And created this ticket:
https://trac.cppcheck.net/ticket/9947
Many thanks.