[llvm] ca4e5a8 - [Memprof] Fixes memory leak in MemInfoBlock histogram. (#96834)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 17:11:25 PDT 2024


Author: Matthew Weingarten
Date: 2024-06-26T17:11:21-07:00
New Revision: ca4e5a8d6e00d8a851c3bbd01442193f97a80139

URL: https://github.com/llvm/llvm-project/commit/ca4e5a8d6e00d8a851c3bbd01442193f97a80139
DIFF: https://github.com/llvm/llvm-project/commit/ca4e5a8d6e00d8a851c3bbd01442193f97a80139.diff

LOG: [Memprof] Fixes memory leak in MemInfoBlock histogram. (#96834)

MemInfoBlocks (MIB) with empty callstacks are erased prematurely from
the CallStackProfileData. This patch frees allocated histogram buffers
when the MIB is associated with an empty callstack.

Added: 
    

Modified: 
    llvm/lib/ProfileData/MemProfReader.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp
index 85327273d6d7b..5e2d76e24dab7 100644
--- a/llvm/lib/ProfileData/MemProfReader.cpp
+++ b/llvm/lib/ProfileData/MemProfReader.cpp
@@ -633,6 +633,8 @@ Error RawMemProfReader::symbolizeAndFilterStackFrames(
   // Drop the entries where the callstack is empty.
   for (const uint64_t Id : EntriesToErase) {
     StackMap.erase(Id);
+    if(CallstackProfileData[Id].AccessHistogramSize > 0)
+      free((void*) CallstackProfileData[Id].AccessHistogram);
     CallstackProfileData.erase(Id);
   }
 


        


More information about the llvm-commits mailing list