summaryrefslogtreecommitdiff
path: root/src/system-alloc.cc
diff options
context:
space:
mode:
authorcsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2007-11-29 23:39:24 +0000
committercsilvers <csilvers@6b5cf1ce-ec42-a296-1ba9-69fdba395a50>2007-11-29 23:39:24 +0000
commit11b02f7aebd05cf39f6f93bdd48786909f99f34e (patch)
tree660c613e74cffd643ee4a7d0f0cb170057abbf7d /src/system-alloc.cc
parent49b74b9508797f8aafe6b86e62e7efc4ec200e48 (diff)
downloadgperftools-11b02f7aebd05cf39f6f93bdd48786909f99f34e.tar.gz
Thu Nov 29 07:59:43 2007 Google Inc. <opensource@google.com>
* google-perftools: version 0.94 release * PORTING: MinGW/Msys support -- runs same code as MSVC does (csilvers) * PORTING: Add NumCPUs support for Mac OS X (csilvers) * Work around a sscanf bug in glibc(?) (waldemar) * Fix Windows MSVC bug triggered by thread deletion (csilvers) * Fix bug that triggers in MSVC /O2: missing volatile (gpike) * March-of-time support: quiet warnings/errors for gcc 4.2, OS X 10.5 * Modify pprof so it works without nm: useful for windows (csilvers) * pprof: Support filtering for CPU profiles (cgd) * Bugfix: have realloc report to hooks in all situations (maxim) * Speed improvement: replace slow memcpy with std::copy (soren) * Speed: better iterator efficiency in RecordRegionRemoval (soren) * Speed: minor speed improvements via better bitfield alignment (gpike) * Documentation: add documentation of binary profile output (cgd) git-svn-id: http://gperftools.googlecode.com/svn/trunk@40 6b5cf1ce-ec42-a296-1ba9-69fdba395a50
Diffstat (limited to 'src/system-alloc.cc')
-rw-r--r--src/system-alloc.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/system-alloc.cc b/src/system-alloc.cc
index 8b400aa..96906ca 100644
--- a/src/system-alloc.cc
+++ b/src/system-alloc.cc
@@ -97,6 +97,7 @@ public:
SbrkSysAllocator() : SysAllocator() {
}
void* Alloc(size_t size, size_t *actual_size, size_t alignment);
+ void DumpStats(TCMalloc_Printer* printer);
};
static char sbrk_space[sizeof(SbrkSysAllocator)];
@@ -105,6 +106,7 @@ public:
MmapSysAllocator() : SysAllocator() {
}
void* Alloc(size_t size, size_t *actual_size, size_t alignment);
+ void DumpStats(TCMalloc_Printer* printer);
};
static char mmap_space[sizeof(MmapSysAllocator)];
@@ -113,6 +115,7 @@ public:
DevMemSysAllocator() : SysAllocator() {
}
void* Alloc(size_t size, size_t *actual_size, size_t alignment);
+ void DumpStats(TCMalloc_Printer* printer);
};
static char devmem_space[sizeof(DevMemSysAllocator)];
@@ -126,7 +129,7 @@ bool RegisterSystemAllocator(SysAllocator *a, int priority) {
// No two allocators should have a priority conflict, since the order
// is determined at compile time.
- CHECK(allocators[priority] == NULL);
+ CHECK_CONDITION(allocators[priority] == NULL);
allocators[priority] = a;
return true;
}
@@ -179,6 +182,10 @@ void* SbrkSysAllocator::Alloc(size_t size, size_t *actual_size,
return reinterpret_cast<void*>(ptr);
}
+void SbrkSysAllocator::DumpStats(TCMalloc_Printer* printer) {
+ printer->printf("SbrkSysAllocator: failed_=%d\n", failed_);
+}
+
void* MmapSysAllocator::Alloc(size_t size, size_t *actual_size,
size_t alignment) {
// could theoretically return the "extra" bytes here, but this
@@ -234,6 +241,10 @@ void* MmapSysAllocator::Alloc(size_t size, size_t *actual_size,
return reinterpret_cast<void*>(ptr);
}
+void MmapSysAllocator::DumpStats(TCMalloc_Printer* printer) {
+ printer->printf("MmapSysAllocator: failed_=%d\n", failed_);
+}
+
void* DevMemSysAllocator::Alloc(size_t size, size_t *actual_size,
size_t alignment) {
static bool initialized = false;
@@ -322,6 +333,10 @@ void* DevMemSysAllocator::Alloc(size_t size, size_t *actual_size,
return reinterpret_cast<void*>(ptr);
}
+void DevMemSysAllocator::DumpStats(TCMalloc_Printer* printer) {
+ printer->printf("DevMemSysAllocator: failed_=%d\n", failed_);
+}
+
static bool system_alloc_inited = false;
void InitSystemAllocators(void) {
// This determines the order in which system allocators are called
@@ -403,3 +418,13 @@ void TCMalloc_SystemRelease(void* start, size_t length) {
}
#endif
}
+
+void DumpSystemAllocatorStats(TCMalloc_Printer* printer) {
+ for (int j = 0; j < kMaxAllocators; j++) {
+ SysAllocator *a = allocators[j];
+ if (a == NULL) continue;
+ if (a->usable_) {
+ a->DumpStats(printer);
+ }
+ }
+}