diff options
author | Cristian Cadar <cristic@cs.stanford.edu> | 2012-01-18 18:58:10 +0000 |
---|---|---|
committer | Cristian Cadar <cristic@cs.stanford.edu> | 2012-01-18 18:58:10 +0000 |
commit | d32d0df34ab754d4d3b27b287092e536f03a231c (patch) | |
tree | 7d76e832672acd1ba11e2b3696b751d3baeee68a /lib/Core/Memory.h | |
parent | 5344817c3de946e0636f6f671749c464dc4c02f2 (diff) | |
download | klee-d32d0df34ab754d4d3b27b287092e536f03a231c.tar.gz |
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
Diffstat (limited to 'lib/Core/Memory.h')
-rw-r--r-- | lib/Core/Memory.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Core/Memory.h b/lib/Core/Memory.h index 9ce8e09b..637f8772 100644 --- a/lib/Core/Memory.h +++ b/lib/Core/Memory.h @@ -30,9 +30,12 @@ class Solver; class MemoryObject { friend class STPBuilder; + friend class ObjectState; + friend class ExecutionState; private: static int counter; + mutable unsigned refCount; public: unsigned id; @@ -50,6 +53,8 @@ public: bool fake_object; bool isUserSpecified; + MemoryManager *parent; + /// "Location" for which this memory object was allocated. This /// should be either the allocating instruction or the global object /// it was allocated for (or whatever else makes sense). @@ -69,17 +74,21 @@ public: // XXX this is just a temp hack, should be removed explicit MemoryObject(uint64_t _address) - : id(counter++), + : refCount(0), + id(counter++), address(_address), size(0), isFixed(true), + parent(NULL), allocSite(0) { } MemoryObject(uint64_t _address, unsigned _size, bool _isLocal, bool _isGlobal, bool _isFixed, - const llvm::Value *_allocSite) - : id(counter++), + const llvm::Value *_allocSite, + MemoryManager *_parent) + : refCount(0), + id(counter++), address(_address), size(_size), name("unnamed"), @@ -88,6 +97,7 @@ public: isFixed(_isFixed), fake_object(false), isUserSpecified(false), + parent(_parent), allocSite(_allocSite) { } |