examples_cpp icon indicating copy to clipboard operation
examples_cpp copied to clipboard

Leaking memory?

Open Dr4k3z opened this issue 2 months ago • 0 comments

The custom deleter lambda function is not actually deleting the object.

https://github.com/eth-cscs/examples_cpp/blob/ed913202222dbdc45066900da7ab408249587bfd/Code/SmartPtrs/deleters_7.cpp#L34

Isn't this leaking memory? I guess the correct version should be

auto deleter = [fileName](Object* ptr){
            ptr->dumpToFile(fileName);
            delete ptr;
};

Dr4k3z avatar Oct 28 '25 10:10 Dr4k3z