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

Unified Diff: Source/wtf/PartitionAlloc.cpp

Issue 254103003: PartitionAlloc: Make in-place realloc() less likely to happen (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: extended test Created 6 years, 8 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
« no previous file with comments | « Source/wtf/PartitionAlloc.h ('k') | Source/wtf/PartitionAllocTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PartitionAlloc.cpp
diff --git a/Source/wtf/PartitionAlloc.cpp b/Source/wtf/PartitionAlloc.cpp
index dc284080b30c65526498434099140c38135d2e0d..54bae29d25886b498955be4490f859924b12330d 100644
--- a/Source/wtf/PartitionAlloc.cpp
+++ b/Source/wtf/PartitionAlloc.cpp
@@ -810,6 +810,13 @@ bool partitionReallocDirectMappedInPlace(PartitionRootGeneric* root, PartitionPa
char* charPtr = static_cast<char*>(partitionPageToPointer(page));
if (newSize < currentSize) {
+ size_t mapSize = partitionPageToDirectMapExtent(page)->mapSize;
+
+ // Don't reallocate in-place if new size is less than 80 % of the full
+ // map size, to avoid holding on to too much unused address space.
+ if ((newSize / kSystemPageSize) * 5 < (mapSize / kSystemPageSize) * 4)
+ return false;
+
// Shrink by decommitting unneeded pages and making them inaccessible.
size_t decommitSize = currentSize - newSize;
decommitSystemPages(charPtr + newSize, decommitSize);
« no previous file with comments | « Source/wtf/PartitionAlloc.h ('k') | Source/wtf/PartitionAllocTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698