Debugger: Further work on memory leak hunting.

TeamWindow:
- Properly delete stack frame selection entries in destructor.

TeamDebugger:
- The reference to TeamDebugInfo wasn't correctly initialized to own,
  leading to TeamDebugInfo never being destroyed.

FunctionInstance:
- Also clear source code reference in destructor.

ImageDebugInfo:
- Release references to specific infos in destructor. These are acquired
  on our behalf when loading the image info, but were never released,
  leading to the latter never being freed.

DwarfManager:
- Release references to files in destructor.

FileManager:
- Release entries in various destructors.

Somewhat improves the situation in #13800, but is still far from complete,
as a thorough review of this nature hasn't ever really been done.
This commit is contained in:
Rene Gollent 2017-12-28 23:22:13 -05:00
parent 8bb774fc37
commit 3d9b569384
6 changed files with 36 additions and 4 deletions

View File

@ -282,6 +282,16 @@ TeamWindow::~TeamWindow()
_SetActiveThread(NULL);
delete fFilePanel;
ThreadStackFrameSelectionEntry* entry
= fThreadSelectionInfoTable->Clear(true);
while (entry != NULL) {
ThreadStackFrameSelectionEntry* next = entry->next;
delete entry;
entry = next;
}
delete fThreadSelectionInfoTable;
if (fActiveSourceWorker > 0)

View File

@ -366,7 +366,7 @@ TeamDebugger::Init(DebuggerInterface* interface, thread_id threadID, int argc,
fFileManager);
if (teamDebugInfo == NULL)
return B_NO_MEMORY;
BReference<TeamDebugInfo> teamDebugInfoReference(teamDebugInfo);
BReference<TeamDebugInfo> teamDebugInfoReference(teamDebugInfo, true);
error = teamDebugInfo->Init();
if (error != B_OK)

View File

@ -32,6 +32,7 @@ FunctionInstance::FunctionInstance(ImageDebugInfo* imageDebugInfo,
FunctionInstance::~FunctionInstance()
{
SetFunction(NULL);
SetSourceCode(NULL, FUNCTION_SOURCE_NOT_LOADED);
fFunctionDebugInfo->ReleaseReference();
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2010-2013, Rene Gollent, rene@gollent.com.
* Copyright 2010-2017, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@ -27,12 +27,18 @@ ImageDebugInfo::~ImageDebugInfo()
{
for (int32 i = 0; FunctionInstance* function = fFunctions.ItemAt(i); i++)
function->ReleaseReference();
for (int32 i = 0; SpecificImageDebugInfo* info = fSpecificInfos.ItemAt(i);
i++) {
info->ReleaseReference();
}
}
bool
ImageDebugInfo::AddSpecificInfo(SpecificImageDebugInfo* info)
{
// NB: on success we take over the caller's reference to the info object
return fSpecificInfos.AddItem(info);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2014, Rene Gollent, rene@gollent.com.
* Copyright 2014-2017, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@ -25,6 +25,8 @@ DwarfManager::DwarfManager(uint8 addressSize)
DwarfManager::~DwarfManager()
{
while (DwarfFile* file = fFiles.RemoveHead())
file->ReleaseReference();
}

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011-2016, Rene Gollent, rene@gollent.com.
* Copyright 2011-2017, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@ -118,6 +118,12 @@ public:
~Domain()
{
LocatableEntry* entry = fEntries.Clear(true);
while (entry != NULL) {
LocatableEntry* next = entry->fNext;
entry->ReleaseReference();
entry = next;
}
}
status_t Init()
@ -555,6 +561,13 @@ FileManager::~FileManager()
{
delete fTargetDomain;
delete fSourceDomain;
SourceFileEntry* entry = fSourceFiles->Clear();
while (entry != NULL) {
SourceFileEntry* next = entry->next;
delete entry;
next = entry;
}
delete fSourceFiles;
}