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

Side by Side Diff: Source/wtf/PartitionAlloc.cpp

Issue 1155293007: Expose ReleaseFreeMemory to free up memory on memory pressure or idle cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing test calls. Created 5 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 unified diff | Download patch
« no previous file with comments | « Source/wtf/PartitionAlloc.h ('k') | Source/wtf/PartitionAllocTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 // we really free it. This improves performance, particularly on Mac OS X 856 // we really free it. This improves performance, particularly on Mac OS X
857 // which has subpar memory management performance. 857 // which has subpar memory management performance.
858 root->globalEmptyPageRing[currentIndex] = page; 858 root->globalEmptyPageRing[currentIndex] = page;
859 page->emptyCacheIndex = currentIndex; 859 page->emptyCacheIndex = currentIndex;
860 ++currentIndex; 860 ++currentIndex;
861 if (currentIndex == kMaxFreeableSpans) 861 if (currentIndex == kMaxFreeableSpans)
862 currentIndex = 0; 862 currentIndex = 0;
863 root->globalEmptyPageRingIndex = currentIndex; 863 root->globalEmptyPageRingIndex = currentIndex;
864 } 864 }
865 865
866 void partitionPurgeMemory(PartitionRootBase* root) 866 static void partitionDecommitFreePages(PartitionRootBase* root)
867 { 867 {
868 for (size_t i = 0; i < kMaxFreeableSpans; ++i) { 868 for (size_t i = 0; i < kMaxFreeableSpans; ++i) {
869 PartitionPage* page = root->globalEmptyPageRing[i]; 869 PartitionPage* page = root->globalEmptyPageRing[i];
870 if (page) 870 if (page)
871 partitionDecommitPageIfPossible(root, page); 871 partitionDecommitPageIfPossible(root, page);
872 root->globalEmptyPageRing[i] = nullptr; 872 root->globalEmptyPageRing[i] = nullptr;
873 } 873 }
874 } 874 }
875 875
876 void partitionPurgeMemory(PartitionRoot* root)
877 {
878 partitionDecommitFreePages(root);
879 }
880
881 void partitionPurgeMemoryGeneric(PartitionRootGeneric* root)
882 {
883 spinLockLock(&root->lock);
884 partitionDecommitFreePages(root);
885 spinLockUnlock(&root->lock);
886 }
887
876 void partitionFreeSlowPath(PartitionPage* page) 888 void partitionFreeSlowPath(PartitionPage* page)
877 { 889 {
878 PartitionBucket* bucket = page->bucket; 890 PartitionBucket* bucket = page->bucket;
879 ASSERT(page != &PartitionRootGeneric::gSeedPage); 891 ASSERT(page != &PartitionRootGeneric::gSeedPage);
880 if (LIKELY(page->numAllocatedSlots == 0)) { 892 if (LIKELY(page->numAllocatedSlots == 0)) {
881 // Page became fully unused. 893 // Page became fully unused.
882 if (UNLIKELY(partitionBucketIsDirectMapped(bucket))) { 894 if (UNLIKELY(partitionBucketIsDirectMapped(bucket))) {
883 partitionDirectUnmap(page); 895 partitionDirectUnmap(page);
884 return; 896 return;
885 } 897 }
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 // partitionsDumpBucketStats is called after collecting stats because it 1177 // partitionsDumpBucketStats is called after collecting stats because it
1166 // can use PartitionAlloc to allocate and this can affect the statistics. 1178 // can use PartitionAlloc to allocate and this can affect the statistics.
1167 for (size_t i = 0; i < partitionNumBuckets; ++i) { 1179 for (size_t i = 0; i < partitionNumBuckets; ++i) {
1168 if (memoryStats[i].isValid) 1180 if (memoryStats[i].isValid)
1169 partitionStatsDumper->partitionsDumpBucketStats(partitionName, &memo ryStats[i]); 1181 partitionStatsDumper->partitionsDumpBucketStats(partitionName, &memo ryStats[i]);
1170 } 1182 }
1171 } 1183 }
1172 1184
1173 } // namespace WTF 1185 } // namespace WTF
1174 1186
OLDNEW
« 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