intptr_t freed_bytes = 0;
int pages_swept = 0;
- intptr_t newspace_size = space->heap()->new_space()->Size();
bool lazy_sweeping_active = false;
bool unused_page_present = false;
}
freed_bytes += SweepConservatively(space, p);
pages_swept++;
- if (freed_bytes > 2 * newspace_size) {
- space->SetPagesToSweep(p->next_page());
- lazy_sweeping_active = true;
- } else {
- if (FLAG_gc_verbose) {
- PrintF("Only %" V8PRIdPTR " bytes freed. Still sweeping.\n",
- freed_bytes);
- }
- }
+ space->SetPagesToSweep(p->next_page());
+ lazy_sweeping_active = true;
break;
}
case PRECISE: {
HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) {
// Allocation in this space has failed.
- // If there are unswept pages advance lazy sweeper then sweep one page before
- // allocating a new page.
- if (first_unswept_page_->is_valid()) {
- AdvanceSweeper(size_in_bytes);
+ // If there are unswept pages advance lazy sweeper a bounded number of times
+ // until we find a size_in_bytes contiguous piece of memory
+ const int kMaxSweepingTries = 5;
+ bool sweeping_complete = false;
+
+ for (int i = 0; i < kMaxSweepingTries && !sweeping_complete; i++) {
+ sweeping_complete = AdvanceSweeper(size_in_bytes);
// Retry the free list allocation.
HeapObject* object = free_list_.Allocate(size_in_bytes);