Sgenmi / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Fix page_heap_test for system with different page size #552

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
PowerPC uses 64K page size instead of 4k for x86 and x86_64. It makes the
page_heap_test fails because the following test:

 static bool HaveSystemRelease =
    TCMalloc_SystemRelease(TCMalloc_SystemAlloc(kPageSize, NULL, 0), kPageSize);

will always fail if kPageSize is less than getpagesize() (the default
configuration).

The following patch fixes it by trying to allocate/deallocate an entire
page instead:

Index: src/tests/page_heap_test.cc
===================================================================
--- src/tests/page_heap_test.cc (revision 226)
+++ src/tests/page_heap_test.cc (working copy)
@@ -12,8 +12,11 @@

 namespace {

+// The system will only release memory if the block size is equal or hight than
+// system page size.
 static bool HaveSystemRelease =
-    TCMalloc_SystemRelease(TCMalloc_SystemAlloc(kPageSize, NULL, 0), 
kPageSize);
+    TCMalloc_SystemRelease(
+      TCMalloc_SystemAlloc(getpagesize(), NULL, 0), getpagesize());

 static void CheckStats(const tcmalloc::PageHeap* ph,
                        uint64_t system_pages,

Original issue reported on code.google.com by zatr...@gmail.com on 21 Jul 2013 at 11:55

GoogleCodeExporter commented 9 years ago
merged. Thanks.

Original comment by alkondratenko on 26 Jul 2013 at 6:19