From d32d0df34ab754d4d3b27b287092e536f03a231c Mon Sep 17 00:00:00 2001 From: Cristian Cadar Date: Wed, 18 Jan 2012 18:58:10 +0000 Subject: Nice patch by Gang Hu, Heming Cui and Junfeng Yang fixing a memory leak in KLEE. From Gang Hu: "The memory leak is caused by two reasons. First, the MemoryObject objects are not freed, until the MemoryManager is destroyed. Second, when KLEE allocates a non-fixed MemoryObject object, KLEE also allocates a block of memory which is the same as the object's size. This block of memory is never freed. So, this patch generally does reference counting on the MemoryObject objects, and frees them as soon as the reference count drops to zero." Many thanks to Paul Marinescu as well, who tested this patch thoroughly on the Coreutils benchmarks. On 1h runs, the memory consumption typically goes down by 1-5%, but some applications which see more significant gains. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@148402 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Core/MemoryManager.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/Core/MemoryManager.h') diff --git a/lib/Core/MemoryManager.h b/lib/Core/MemoryManager.h index adb2ba22..f398db62 100644 --- a/lib/Core/MemoryManager.h +++ b/lib/Core/MemoryManager.h @@ -10,7 +10,7 @@ #ifndef KLEE_MEMORYMANAGER_H #define KLEE_MEMORYMANAGER_H -#include +#include #include namespace llvm { @@ -22,7 +22,7 @@ namespace klee { class MemoryManager { private: - typedef std::vector objects_ty; + typedef std::set objects_ty; objects_ty objects; public: @@ -34,6 +34,7 @@ namespace klee { MemoryObject *allocateFixed(uint64_t address, uint64_t size, const llvm::Value *allocSite); void deallocate(const MemoryObject *mo); + void markFreed(MemoryObject *mo); }; } // End klee namespace -- cgit 1.4.1