diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index fc530b16..018c284d 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -157,6 +157,13 @@ namespace MemoryManager used_mem += ARCH_PAGE_SIZE; free_mem -= ARCH_PAGE_SIZE; + if (free_mem < 1024 * 1024) + { + // Less than 1 MiB of free memory! Let's start clearing caches... + kwarnln("Less than 1 MiB of free memory, clearing caches to try to gain extra memory"); + Scheduler::signal_oom_thread(); + } + return index * ARCH_PAGE_SIZE; }