From e62ff396e3b23b62759e20fab45d2e28b4766a64 Mon Sep 17 00:00:00 2001 From: Maciej Pawel Szymanski <maciej.szymanski@cern.ch> Date: Tue, 19 Mar 2024 17:46:29 +0100 Subject: [PATCH] Improve the condition for setting the address for proxy and releasing the address object Improve the condition for setting the address for proxy It's a follow-up from https://gitlab.cern.ch/atlas/athena/-/merge_requests/67465/ and https://gitlab.cern.ch/atlas/athena/-/merge_requests/68101 It seems that in 0fc6d9d148f4832d1b058baf07c279ba0863b9b5 we had the ref count off by one which lead to the memory leak reported in https://its.cern.ch/jira/browse/ATLASG-2660. This MR unconditionally releases the addresses, also for the new output objects. --- Control/AthenaServices/src/AthenaOutputStreamTool.cxx | 6 +++--- .../AthenaPoolCnvSvc/T_AthenaPoolCoolMultChanCnv.icc | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Control/AthenaServices/src/AthenaOutputStreamTool.cxx b/Control/AthenaServices/src/AthenaOutputStreamTool.cxx index 8ed1e1fbec10..854a730e10b1 100644 --- a/Control/AthenaServices/src/AthenaOutputStreamTool.cxx +++ b/Control/AthenaServices/src/AthenaOutputStreamTool.cxx @@ -475,13 +475,13 @@ StatusCode AthenaOutputStreamTool::streamObjects(const DataObjectVec& dataObject if (dobj->clID() != 1 || addr->par()[0] != "\n") { if (dobj->clID() != ClassID_traits<DataHeader>::ID()) { m_dataHeader->insert(proxy, addr); - if (m_store->storeID() != StoreID::EVENT_STORE) proxy->setAddress(addr); } else { m_dataHeader->insert(proxy, addr, m_processTag); } - if (m_store->storeID() == StoreID::EVENT_STORE) { - addr->release(); + if (proxy->address() == nullptr) { + proxy->setAddress(addr); } + addr->release(); } } else { ATH_MSG_ERROR("Could not fill Object Refs for DataObject (clid/key):" << dobj->clID() << " " << dobj->name()); diff --git a/Database/AthenaPOOL/AthenaPoolCnvSvc/AthenaPoolCnvSvc/T_AthenaPoolCoolMultChanCnv.icc b/Database/AthenaPOOL/AthenaPoolCnvSvc/AthenaPoolCnvSvc/T_AthenaPoolCoolMultChanCnv.icc index 94bce3ad0dd6..0e9f3ab2f345 100644 --- a/Database/AthenaPOOL/AthenaPoolCnvSvc/AthenaPoolCnvSvc/T_AthenaPoolCoolMultChanCnv.icc +++ b/Database/AthenaPOOL/AthenaPoolCnvSvc/AthenaPoolCnvSvc/T_AthenaPoolCoolMultChanCnv.icc @@ -225,6 +225,7 @@ StatusCode T_AthenaPoolCoolMultChanCnv<COLL_T, ELEM_T, ELEM_P>::createRep(DataOb token->toString()); addr->setAttrListColl(coll); delete pAddr; pAddr = addr; + pAddr->addRef(); delete token; token = 0; ATH_MSG_DEBUG("End createRep"); -- GitLab