-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix memory leak in VectorPDF #42
Conversation
Guarding memory deallocation behind a macro would expose users of root io enabled builds to memory leak. TObject instances are not owned in ROOT, so the code in this PR is valid in both cases.
… On May 20, 2024, at 10:31 AM, Christopher Dilks ***@***.***> wrote:
@c-dilks commented on this pull request.
In include/SinglePDF.h:
> + ~VectorPDF() {
+ for(auto pdf : m_Members) {
+ delete pdf;
+ }
+ };
Since this class inherits from TObject, does streaming instances of VectorPDF to ROOT files still work? If not, or you don't want to test, perhaps use DISABLE_ROOT_IO:
⬇️ Suggested change
- ~VectorPDF() {
- for(auto pdf : m_Members) {
- delete pdf;
- }
- };
+ ~VectorPDF() {
+#ifdef DISABLE_ROOT_IO
+ for(auto pdf : m_Members) {
+ delete pdf;
+ }
+#endif
+ };
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
No auto f = new TFile("f.root");
auto v = new VectorPDF();
// ... things that fill `m_Members` ...
v->Write("v");
f->Close(); |
This wouldn't even work, it's not TNamed. But yes, there is no reason to get double free from that. |
It works on ROOT 6.28;
Ship it! ROOT I/O for this repo is disabled in the |
v1.0.8 tagged since eic/EICrecon#1456 is closed. |
Can someone confirm that this will get ported to IRT2 as well, or included automatically? |
Sure, "obviously", you're right, TKey's can be created for TObject, by calling TObject::Write. |
@veprbl Why did we not catch the memory leak in irt with lsan? Is one of the root suppressions hiding it? Can we narrow it? |
One needs to compile with lsan to detect the leaks. |
Ah right, of course. Duh. |
Resolves: eic/EICrecon#1456
cc #36