* B_LOW_MEMORY_NOTE now starts earlier, at 8 MB left.
* vm_low_memory_state() now periodically recomputes the state in case the low memory thread is waiting for something. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22483 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -40,12 +40,13 @@ static const bigtime_t kLowMemoryInterval = 3000000; // 3 secs
|
|||||||
static const bigtime_t kWarnMemoryInterval = 500000; // 0.5 secs
|
static const bigtime_t kWarnMemoryInterval = 500000; // 0.5 secs
|
||||||
|
|
||||||
// page limits
|
// page limits
|
||||||
static const size_t kNoteLimit = 1024;
|
static const size_t kNoteLimit = 2048;
|
||||||
static const size_t kWarnLimit = 256;
|
static const size_t kWarnLimit = 256;
|
||||||
static const size_t kCriticalLimit = 32;
|
static const size_t kCriticalLimit = 32;
|
||||||
|
|
||||||
|
|
||||||
static int32 sLowMemoryState = B_NO_LOW_MEMORY;
|
static int32 sLowMemoryState = B_NO_LOW_MEMORY;
|
||||||
|
static bigtime_t sLastMeasurement;
|
||||||
|
|
||||||
static mutex sLowMemoryMutex;
|
static mutex sLowMemoryMutex;
|
||||||
static sem_id sLowMemoryWaitSem;
|
static sem_id sLowMemoryWaitSem;
|
||||||
@@ -69,6 +70,8 @@ call_handlers(int32 level)
|
|||||||
static int32
|
static int32
|
||||||
compute_state(void)
|
compute_state(void)
|
||||||
{
|
{
|
||||||
|
sLastMeasurement = system_time();
|
||||||
|
|
||||||
uint32 freePages = vm_page_num_free_pages();
|
uint32 freePages = vm_page_num_free_pages();
|
||||||
if (freePages >= kNoteLimit)
|
if (freePages >= kNoteLimit)
|
||||||
return B_NO_LOW_MEMORY;
|
return B_NO_LOW_MEMORY;
|
||||||
@@ -148,6 +151,9 @@ vm_low_memory(size_t requirements)
|
|||||||
int32
|
int32
|
||||||
vm_low_memory_state(void)
|
vm_low_memory_state(void)
|
||||||
{
|
{
|
||||||
|
if (system_time() - sLastMeasurement > 500000)
|
||||||
|
sLowMemoryState = compute_state();
|
||||||
|
|
||||||
return sLowMemoryState;
|
return sLowMemoryState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user