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

eicrecon::JFactoryPodioT::Set leaks memory #742

Open
veprbl opened this issue Jul 5, 2023 · 1 comment
Open

eicrecon::JFactoryPodioT::Set leaks memory #742

veprbl opened this issue Jul 5, 2023 · 1 comment

Comments

@veprbl
Copy link
Member

veprbl commented Jul 5, 2023

template <typename T>
void JFactoryPodioT<T>::Set(const std::vector<T*>& aData) {
typename PodioTypeMap<T>::collection_t collection;
if (mIsSubsetCollection) collection.setSubsetCollection(true);
for (T* item : aData) {
collection.push_back(*item);
}
SetCollection(std::move(collection));
}

copies objects and allows to leak memory (violates guarantees given by the Set method in JANA2). This causes actual leaks in the calorimetry factories.

See also #731

@nathanwbrei
Copy link
Contributor

Thanks for reopening this. It looks like the fix is simply to delete item after each collection.push_back(*item)? Even though this code is in eicrecon it really should be filed as a JANA issue as well since eicrecon::JFactoryPodioT is a standin for jana::JFactoryPodioT until we move to JANA2 v2.1.1. All that being said, we should really be calling SetCollection() instead because calling delete on every object is wildly inefficient.

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

No branches or pull requests

2 participants