From 941a7a240cf02dc58a9b6324f08ef1bfbdf08f9c Mon Sep 17 00:00:00 2001 From: pdn Date: Fri, 22 Nov 2013 13:07:17 +0400 Subject: [PATCH] 0024380: OSD_MAllocHook - Improvement of malloc hook to follow maximal peack size --- src/OSD/OSD_MAllocHook.cxx | 14 +++++++++++++- src/OSD/OSD_MAllocHook.hxx | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/OSD/OSD_MAllocHook.cxx b/src/OSD/OSD_MAllocHook.cxx index ab7a7a50ae..d0f1eccfb8 100755 --- a/src/OSD/OSD_MAllocHook.cxx +++ b/src/OSD/OSD_MAllocHook.cxx @@ -470,7 +470,8 @@ OSD_MAllocHook::CollectBySize::CollectBySize() : myArray(NULL), myTotalLeftSize(0), myTotalPeakSize(0), - myBreakSize(0) + myBreakSize(0), + myBreakPeak(0) { Reset(); } @@ -587,7 +588,18 @@ void OSD_MAllocHook::CollectBySize::AllocEvent myTotalLeftSize += theSize; int nbLeft = myArray[ind].nbAlloc - myArray[ind].nbFree; if (nbLeft > myArray[ind].nbLeftPeak) + { myArray[ind].nbLeftPeak = nbLeft; + if (myBreakPeak != 0 + && (myBreakSize == theSize || myBreakSize == 0)) + { + const Standard_Size aSizePeak = myArray[ind].nbLeftPeak * theSize; + if (aSizePeak > myBreakPeak) + { + place_for_breakpoint(); + } + } + } if (myTotalLeftSize > (ptrdiff_t)myTotalPeakSize) myTotalPeakSize = myTotalLeftSize; myMutex.Unlock(); diff --git a/src/OSD/OSD_MAllocHook.hxx b/src/OSD/OSD_MAllocHook.hxx index 58ae3038cc..5484504351 100755 --- a/src/OSD/OSD_MAllocHook.hxx +++ b/src/OSD/OSD_MAllocHook.hxx @@ -148,7 +148,8 @@ public: Numbers* myArray; //!< indexed from 0 to myMaxAllocSize-1 ptrdiff_t myTotalLeftSize; //!< currently remained allocated size size_t myTotalPeakSize; //!< maxium cumulative allocated size - size_t myBreakSize; + size_t myBreakSize; //!< user defined allocation size to debug (see place_for_breakpoint()) + size_t myBreakPeak; //!< user defined peak size limit to debug }; //! Set handler of allocation/deallocation events