From 14438ad555dd193fffe0dfbef669778af2358a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 27 Mar 2008 09:38:53 +0000 Subject: [PATCH] * write_cached_block() now moves a block to the unused list when it's not referenced and clean (is no longer part of a transaction). This finally gets memory consumption to a moderate level; even unpacking a large archive will no longer eat all memory. * The "block_cache" KDL command will now print the number of unused blocks as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24606 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/cache/block_cache.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index 155a8adad3..173d6921ee 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -861,6 +861,11 @@ write_cached_block(block_cache *cache, cached_block *block, } } } + if (block->transaction == NULL && block->ref_count == 0) { + // the block is no longer used + block->unused = true; + cache->unused_blocks.Add(block); + } return B_OK; } @@ -1004,8 +1009,8 @@ dump_cache(int argc, char **argv) count++; } - kprintf(" %ld blocks total, %ld dirty, %ld referenced.\n", count, dirty, - referenced); + kprintf(" %ld blocks total, %ld dirty, %ld referenced, %ld in unused.\n", count, dirty, + referenced, cache->unused_blocks.Size()); hash_close(cache->hash, &iterator, false); return 0;