-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak for objects allocated in ctor of user defined class during I/O #16375
Comments
Hi, Could you explain why the classes are forced not to be selected without the "+", which brings many benefits, among which performance during the IO procedures? |
In the case for GENIE neutrino generator, its a software with a long history, I am unable to trace back to the time when the And it seems that adding the plus sign will break some compatibility with root files generated without the plus sign, so that's not going to be easy. |
We are no longer updating the old I/O (the one you get without the However you can straightforwardly migrate to the new I/O and solve the problem for you classes. The result of the process applied to your example can be seen in the merge request against your example: karuboniru/root_memory_leak_report#1 This was created (beside the small tidying commits) by:
After this steps, there is no change in behavior yet.
This accomplish in karuboniru/root_memory_leak_report@ After this step the new code will write and read new file without a memory lead. It will be able to read the old file with the same memory as before.
This is seen in karuboniru/root_memory_leak_report@ After this we have:
|
Check duplicate issues.
Description
If a class allocates memory in its ctor (and deallocates in dtor). And included in
LinkDef.h
without+
after class name. During I/O, the ctor will be called but not the dtor.Reproducer
Please refer to this code: https:/karuboniru/root_memory_leak_report
It compiles to
gen
,read{,_old}
.gen
produces a.root
file containing a tree of user defined classTestData
. Andread
read_old
read the tree to do something.read
uses RDataFrame language andread_old
uses oldSetBranchAddress
way.In the constructor of TestData, it will allocate memory for class
a_member
. And deallocate it in its destructor. Any call to the constructor or destructor of classa_member
will be logged.If
#pragma link C++ class TestData;
, instead of#pragma link C++ class TestData+;
is in theLinkDef.h
, the read program will contain multiple call toa_member::a_member
but only single or none call toa_member::~a_member
, potenially causing memory leak per entry processed.ROOT version
Installation method
reproducable from self build (from copr), from fedora repo (official version) and ROOT from
/cvmfs/sft.cern.ch/lcg/views/LCG_106/x86_64-el9-gcc13-opt/setup.sh
Operating system
Linux Fedora 41 and CentOS9
Additional context
This issue seems to be causing massive memory leak with GENIE. The GENIE related tools manually cleans the resources but it seems I can't do the same with RDataFrame.
The text was updated successfully, but these errors were encountered: