Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: third_party/tcmalloc/chromium/src/tests/frag_unittest.cc

Issue 7050034: Merge google-perftools r109 (the current contents of third_party/tcmalloc/vendor) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/chromium/src/tests/frag_unittest.cc
===================================================================
--- third_party/tcmalloc/chromium/src/tests/frag_unittest.cc (revision 88335)
+++ third_party/tcmalloc/chromium/src/tests/frag_unittest.cc (working copy)
@@ -44,13 +44,16 @@
#endif
#include <vector>
#include "base/logging.h"
+#include "common.h"
#include <google/malloc_extension.h>
using std::vector;
int main(int argc, char** argv) {
- static const int kAllocSize = 36<<10; // Bigger than tcmalloc page size
- static const int kTotalAlloc = 400 << 20; // Allocate 400MB in total
+ // Make kAllocSize one page larger than the maximum small object size.
+ static const int kAllocSize = kMaxSize + kPageSize;
+ // Allocate 400MB in total.
+ static const int kTotalAlloc = 400 << 20;
static const int kAllocIterations = kTotalAlloc / kAllocSize;
// Allocate lots of objects
@@ -59,6 +62,11 @@
saved[i] = new char[kAllocSize];
}
+ // Check the current "slack".
+ size_t slack_before;
+ MallocExtension::instance()->GetNumericProperty("tcmalloc.slack_bytes",
+ &slack_before);
+
// Free alternating ones to fragment heap
size_t free_bytes = 0;
for (int i = 0; i < saved.size(); i += 2) {
@@ -66,10 +74,13 @@
free_bytes += kAllocSize;
}
- // Check that slack is within 10% of expected
- size_t slack;
+ // Check that slack delta is within 10% of expected.
+ size_t slack_after;
MallocExtension::instance()->GetNumericProperty("tcmalloc.slack_bytes",
- &slack);
+ &slack_after);
+ CHECK_GE(slack_after, slack_before);
+ size_t slack = slack_after - slack_before;
+
CHECK_GT(double(slack), 0.9*free_bytes);
CHECK_LT(double(slack), 1.1*free_bytes);

Powered by Google App Engine
This is Rietveld 408576698