* If there are no free ranges left, the block cache will now reuse older

blocks - this is not enough, though as it would also need to ask other
  volumes to free ranges.
* Increased the number of blocks to free in case of low memory.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16663 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-03-08 21:43:45 +00:00
parent f951ca0e6a
commit 17372b761e

View File

@ -218,8 +218,17 @@ block_cache::GetFreeRange()
// we need to allocate a new range
block_range *range;
if (block_range::New(this, &range) != B_OK) {
// ToDo: free up space in existing ranges
// We may also need to free ranges from other caches to get a free one
RemoveUnusedBlocks(2, 50);
if (!free_ranges.IsEmpty())
return free_ranges.First();
RemoveUnusedBlocks(LONG_MAX, 50);
if (!free_ranges.IsEmpty())
return free_ranges.First();
// TODO: We also need to free ranges from other caches to get a free one
// (if not, an active volume might have stolen all free ranges already)
return NULL;
}
@ -377,11 +386,11 @@ block_cache::LowMemoryHandler(void *data, int32 level)
case B_NO_LOW_MEMORY:
return;
case B_LOW_MEMORY_NOTE:
free = 10;
free = 50;
accessed = 2;
break;
case B_LOW_MEMORY_WARNING:
free = 50;
free = 200;
accessed = 10;
break;
case B_LOW_MEMORY_CRITICAL: