JeffersonLab / ccdb

Jefferson Lab Calibration and Conditions Database (CCDB)
8 stars 14 forks source link

Memory leak in C++ library? #61

Closed sdobbs closed 4 months ago

sdobbs commented 5 years ago

I have been hunting down some memory problems which are causing hd_root jobs to crash, and came across a possible memory leak in ccdb::StringUtils::vFormat() located in src/Library/Helpers/StringUtils.cc

I think the issue is that there is a malloc() for a variable buffer in line 67, and then the function ends with line 97:

return string(buffer);

So, this should return a new string variable with a copy of the contents of buffer, but the actual buffer is never freed.

This leaks several MB of memory...

DraTeots commented 5 years ago

Oh! Will put a fix

P.S. Actually for a long time I wanted to throw out that string management. P.P.S It is very sad that even now each c++ project should start either with boost or other side library or with reinventing a wheel. C++20 has some promises but when will we be able to use it? In 2030?

DraTeots commented 4 months ago

vFormat() has been removed, right?