Added block_cache_used_memory() that returns the memory allocated by all

block caches for the block cache buffers.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26836 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-08-06 00:09:31 +00:00
parent 5db876653b
commit c79e66abb7
2 changed files with 23 additions and 1 deletions

View File

@ -14,9 +14,10 @@ extern "C" {
#endif
extern status_t block_cache_init(void);
extern size_t block_cache_used_memory();
#ifdef __cplusplus
}
#endif
#endif /* _KRENEL_BLOCK_CACHE_H */
#endif /* _KERNEL_BLOCK_CACHE_H */

View File

@ -1807,6 +1807,27 @@ block_cache_init(void)
}
extern "C" size_t
block_cache_used_memory()
{
size_t usedMemory = 0;
MutexLocker _(sCachesLock);
DoublyLinkedList<block_cache>::Iterator it = sCaches.GetIterator();
while (block_cache* cache = it.Next()) {
if (cache == (block_cache*)&sMarkCache)
continue;
size_t cacheUsedMemory;
object_cache_get_usage(cache->buffer_cache, &cacheUsedMemory);
usedMemory += cacheUsedMemory;
}
return usedMemory;
}
// #pragma mark - public transaction API