[llvm-commits] [llvm] r129727 - in /llvm/trunk: include/llvm/Support/Allocator.h lib/Support/Allocator.cpp
Ted Kremenek
kremenek at apple.com
Mon Apr 18 15:44:46 PDT 2011
Author: kremenek
Date: Mon Apr 18 17:44:46 2011
New Revision: 129727
URL: http://llvm.org/viewvc/llvm-project?rev=129727&view=rev
Log:
Add BumpPtrAllocator::getTotalMemory() to allow clients to query how much memory a BumpPtrAllocator allocated.
Modified:
llvm/trunk/include/llvm/Support/Allocator.h
llvm/trunk/lib/Support/Allocator.cpp
Modified: llvm/trunk/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=129727&r1=129726&r2=129727&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Allocator.h (original)
+++ llvm/trunk/include/llvm/Support/Allocator.h Mon Apr 18 17:44:46 2011
@@ -177,6 +177,9 @@
unsigned GetNumSlabs() const;
void PrintStats() const;
+
+ /// Compute the total physical memory allocated by this allocator.
+ size_t getTotalMemory() const;
};
/// SpecificBumpPtrAllocator - Same as BumpPtrAllocator but allows only
Modified: llvm/trunk/lib/Support/Allocator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=129727&r1=129726&r2=129727&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Allocator.cpp (original)
+++ llvm/trunk/lib/Support/Allocator.cpp Mon Apr 18 17:44:46 2011
@@ -136,6 +136,14 @@
return NumSlabs;
}
+size_t BumpPtrAllocator::getTotalMemory() const {
+ size_t TotalMemory = 0;
+ for (MemSlab *Slab = CurSlab; Slab != 0; Slab = Slab->NextPtr) {
+ TotalMemory += Slab->Size;
+ }
+ return TotalMemory;
+}
+
void BumpPtrAllocator::PrintStats() const {
unsigned NumSlabs = 0;
size_t TotalMemory = 0;
More information about the llvm-commits
mailing list