Skip to content

Fix memory leak in PixelDigi*Source#1358

Merged
karabowi merged 1 commit intoFairRootGroup:devfrom
ChristianTackeGSI:pr/getobject
Feb 24, 2023
Merged

Fix memory leak in PixelDigi*Source#1358
karabowi merged 1 commit intoFairRootGroup:devfrom
ChristianTackeGSI:pr/getobject

Conversation

@ChristianTackeGSI
Copy link
Copy Markdown
Member

Use valued members instead of heap objects.

FairRootManager::GetObject uses FairSource::ActivateObject as a backend. Let's start and fix the memory handling there.


Checklist:

@ChristianTackeGSI ChristianTackeGSI marked this pull request as ready for review February 21, 2023 18:16
Comment thread examples/MQ/pixelDetector/src/PixelDigiBinSource.cxx Outdated
Comment thread examples/MQ/pixelDetector/src/PixelDigiBinSource.h
Use valued members instead of heap objects.
Comment on lines -137 to +132
if (strcmp(BrName, "PixelDigis"))
*obj = (TObject*)fDigis;
else if (strcmp(BrName, "EventHeader."))
*obj = (TObject*)fEventHeader;
if (strcmp(BrName, "PixelDigis") == 0)
*obj = &fDigis;
else if (strcmp(BrName, "EventHeader.") == 0)
*obj = &fEventHeader;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous strcmp usage here looks like a bug to me! I wonder, why this worked at all before? Or is it not called at all?

Copy link
Copy Markdown
Collaborator

@karabowi karabowi Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a bug, we are not testing this anywhere, I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a wild guess:

The Register that happens in ::Init seeds FairRootManager enough, so that GetObject will not try to Activate?

ioman->Register("PixelDigis", "Pixel", fDigis, kFALSE);

@karabowi karabowi merged commit 00285c8 into FairRootGroup:dev Feb 24, 2023
@ChristianTackeGSI ChristianTackeGSI deleted the pr/getobject branch February 24, 2023 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants