Skip to content
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

Workaround a memory leak with old ROOT IO #417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Framework/Ntuple/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#pragma link C++ class genie::NtpMCJobConfig;
#pragma link C++ class genie::NtpMCRecHeader;
#pragma link C++ class genie::NtpMCRecordI;
#pragma link C++ class genie::NtpMCEventRecord;
#pragma link C++ class genie::NtpMCEventRecord-;
#pragma link C++ class genie::NtpWriter;

#endif
27 changes: 27 additions & 0 deletions src/Framework/Ntuple/NtpMCEventRecord.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "Framework/EventGen/EventRecord.h"
#include "Framework/Messenger/Messenger.h"
#include "TBuffer.h"
#include "Framework/Ntuple/NtpMCEventRecord.h"

using std::endl;
Expand Down Expand Up @@ -75,3 +76,29 @@ void NtpMCEventRecord::Clear(Option_t * /*opt*/)
this->hdr.ievent = 0;
}
//____________________________________________________________________________

// Extracted from the code ROOT generated
// added check-and-delete before streaming to
// avoid memory leak
void NtpMCEventRecord::Streamer(TBuffer &R__b) {
// Stream an object of class genie::NtpMCEventRecord.

UInt_t R__s, R__c;
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v) {
}
genie::NtpMCRecordI::Streamer(R__b);
if (event) {
delete event;
event = nullptr;
}
R__b >> event;
R__b.CheckByteCount(R__s, R__c, ::genie::NtpMCEventRecord::IsA());
} else {
R__c = R__b.WriteVersion(::genie::NtpMCEventRecord::IsA(), kTRUE);
genie::NtpMCRecordI::Streamer(R__b);
R__b << event;
R__b.SetByteCount(R__c, kTRUE);
}
}