From 12d7055fe427c6ab4d8c04d28a9f6a35ade6815c Mon Sep 17 00:00:00 2001 From: Omair Majid Date: Thu, 18 Apr 2019 13:36:25 -0400 Subject: [PATCH] Add a destructor for sos::GCHeap (#24072) The constructor allocates memory via new[]. It should be freed up via delete[] by a destructor to avoid a memory leak. --- src/ToolBox/SOS/Strike/sos.cpp | 5 +++++ src/ToolBox/SOS/Strike/sos.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/ToolBox/SOS/Strike/sos.cpp b/src/ToolBox/SOS/Strike/sos.cpp index bf84e1d..4aacc2a 100644 --- a/src/ToolBox/SOS/Strike/sos.cpp +++ b/src/ToolBox/SOS/Strike/sos.cpp @@ -795,6 +795,11 @@ namespace sos } } + GCHeap::~GCHeap() + { + delete [] mHeaps; + } + ObjectIterator GCHeap::WalkHeap(TADDR start, TADDR stop) const { return ObjectIterator(mHeaps, mNumHeaps, start, stop); diff --git a/src/ToolBox/SOS/Strike/sos.h b/src/ToolBox/SOS/Strike/sos.h index 80608dd..4d154ef 100644 --- a/src/ToolBox/SOS/Strike/sos.h +++ b/src/ToolBox/SOS/Strike/sos.h @@ -752,6 +752,8 @@ namespace sos */ GCHeap(); + ~GCHeap(); + /* Returns an ObjectIterator which allows you to walk the objects on the managed heap. * This ObjectIterator is valid for the duration of the GCHeap's lifetime. Note that * if you specify an address at which you wish to start walking the heap it need -- 2.7.4