issue-489: made tests pass on enabled chromium-style decommitting

This commit is contained in:
Aliaksey Kandratsenka 2014-02-22 13:10:08 -08:00
parent a92fc76f72
commit eb2d69014c
1 changed files with 19 additions and 0 deletions

View File

@ -869,6 +869,23 @@ static size_t GetUnmappedBytes() {
}
#endif
class AggressiveDecommitDisabler {
size_t old_value_;
public:
AggressiveDecommitDisabler() {
MallocExtension *inst = MallocExtension::instance();
bool rv = inst->GetNumericProperty("tcmalloc.aggressive_memory_decommit", &old_value_);
CHECK_CONDITION(rv);
rv = inst->SetNumericProperty("tcmalloc.aggressive_memory_decommit", 0);
CHECK_CONDITION(rv);
}
~AggressiveDecommitDisabler() {
MallocExtension *inst = MallocExtension::instance();
bool rv = inst->SetNumericProperty("tcmalloc.aggressive_memory_decommit", old_value_);
CHECK_CONDITION(rv);
}
};
static void TestReleaseToSystem() {
// Debug allocation mode adds overhead to each allocation which
// messes up all the equality tests here. I just disable the
@ -880,6 +897,8 @@ static void TestReleaseToSystem() {
const double old_tcmalloc_release_rate = FLAGS_tcmalloc_release_rate;
FLAGS_tcmalloc_release_rate = 0;
AggressiveDecommitDisabler disabler;
static const int MB = 1048576;
void* a = malloc(MB);
void* b = malloc(MB);