Changeset 58730 in webkit for trunk/JavaScriptCore/wtf/FastMalloc.cpp
- Timestamp:
- May 3, 2010, 7:39:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/FastMalloc.cpp
r58355 r58730 1274 1274 static const float kScavengePercentage = .5f; 1275 1275 1276 // Number of free committed pages that we want to keep around. 1277 static const size_t kMinimumFreeCommittedPageCount = 512; 1276 // number of span lists to keep spans in when memory is returned. 1277 static const int kMinSpanListsWithSpans = 32; 1278 1279 // Number of free committed pages that we want to keep around. The minimum number of pages used when there 1280 // is 1 span in each of the first kMinSpanListsWithSpans spanlists. Currently 528 pages. 1281 static const size_t kMinimumFreeCommittedPageCount = kMinSpanListsWithSpans * ((1.0f+kMinSpanListsWithSpans) / 2.0f); 1278 1282 1279 1283 #endif … … 1535 1539 size_t targetPageCount = std::max<size_t>(kMinimumFreeCommittedPageCount, free_committed_pages_ - pagesToRelease); 1536 1540 1537 for (int i = kMaxPages; i >= 0 && free_committed_pages_ > targetPageCount; i--) { 1538 SpanList* slist = (static_cast<size_t>(i) == kMaxPages) ? &large_ : &free_[i]; 1539 while (!DLL_IsEmpty(&slist->normal) && free_committed_pages_ > targetPageCount) { 1540 Span* s = slist->normal.prev; 1541 DLL_Remove(s); 1542 ASSERT(!s->decommitted); 1543 if (!s->decommitted) { 1544 TCMalloc_SystemRelease(reinterpret_cast<void*>(s->start << kPageShift), 1545 static_cast<size_t>(s->length << kPageShift)); 1546 ASSERT(free_committed_pages_ >= s->length); 1547 free_committed_pages_ -= s->length; 1548 s->decommitted = true; 1541 while (free_committed_pages_ > targetPageCount) { 1542 for (int i = kMaxPages; i > 0 && free_committed_pages_ >= targetPageCount; i--) { 1543 SpanList* slist = (static_cast<size_t>(i) == kMaxPages) ? &large_ : &free_[i]; 1544 // If the span size is bigger than kMinSpanListsWithSpans pages return all the spans in the list, else return all but 1 span. 1545 // Return only 50% of a spanlist at a time so spans of size 1 are not the only ones left. 1546 size_t numSpansToReturn = (i > kMinSpanListsWithSpans) ? DLL_Length(&slist->normal) : static_cast<size_t>(.5 * DLL_Length(&slist->normal)); 1547 for (int j = 0; static_cast<size_t>(j) < numSpansToReturn && !DLL_IsEmpty(&slist->normal) && free_committed_pages_ > targetPageCount; j++) { 1548 Span* s = slist->normal.prev; 1549 DLL_Remove(s); 1550 ASSERT(!s->decommitted); 1551 if (!s->decommitted) { 1552 TCMalloc_SystemRelease(reinterpret_cast<void*>(s->start << kPageShift), 1553 static_cast<size_t>(s->length << kPageShift)); 1554 ASSERT(free_committed_pages_ >= s->length); 1555 free_committed_pages_ -= s->length; 1556 s->decommitted = true; 1557 } 1558 DLL_Prepend(&slist->returned, s); 1549 1559 } 1550 DLL_Prepend(&slist->returned, s);1551 1560 } 1552 1561 }
Note:
See TracChangeset
for help on using the changeset viewer.