Kernel: Shell 'memory' now prints heap memory usage

This commit is contained in:
Bananymous
2023-06-03 02:22:18 +03:00
parent d4289f9e74
commit 2b901abfb1
5 changed files with 40 additions and 1 deletions

View File

@@ -74,4 +74,22 @@ namespace Kernel
ASSERT_NOT_REACHED();
}
size_t Heap::used_pages() const
{
LockGuard _(m_lock);
size_t result = 0;
for (const auto& range : m_physical_ranges)
result += range.used_pages();
return result;
}
size_t Heap::free_pages() const
{
LockGuard _(m_lock);
size_t result = 0;
for (const auto& range : m_physical_ranges)
result += range.free_pages();
return result;
}
}