The JSC garbage collector returns memory to the operating system too
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 31 Jul 2011 19:03:51 +0000 (19:03 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 31 Jul 2011 19:03:51 +0000 (19:03 +0000)
commit07148b12d7e7c7a5f2a186e10acdd810f7b880df
treeef7221896caae2cb3c15bf1fa334f64b6ef61374
parent8a2d14d7c2461ef79ced8e0a6bc839a89a9d4fdb
The JSC garbage collector returns memory to the operating system too
eagerly.
https://bugs.webkit.org/show_bug.cgi?id=65382

Reviewed by Oliver Hunt.

This introduces a memory reuse model similar to the one in FastMalloc.
A periodic scavenger thread runs in the background and returns half the
free memory to the OS on each timer fire.  New block allocations first
attempt to get the memory from the collector's internal pool, reverting
to OS allocation only when this pool is empty.

* heap/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::~Heap):
(JSC::Heap::destroy):
(JSC::Heap::waitForRelativeTimeWhileHoldingLock):
(JSC::Heap::waitForRelativeTime):
(JSC::Heap::blockFreeingThreadStartFunc):
(JSC::Heap::blockFreeingThreadMain):
(JSC::Heap::allocateBlock):
(JSC::Heap::freeBlocks):
(JSC::Heap::releaseFreeBlocks):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::destroy):
(JSC::MarkedBlock::MarkedBlock):
(JSC::MarkedBlock::initForCellSize):
(JSC::MarkedBlock::reset):
* heap/MarkedBlock.h:
* wtf/Platform.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@92084 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/MarkedBlock.cpp
Source/JavaScriptCore/heap/MarkedBlock.h
Source/JavaScriptCore/wtf/Platform.h