kernel: Start clearing caches when free memory is lower than 1MiB
All checks were successful
continuous-integration/drone/pr Build is passing

This is done to avoid returning ENOMEM errors when cache memory can still be reclaimed.
This commit is contained in:
apio 2023-09-20 19:49:13 +02:00
parent b370a99aa6
commit b42497e05e
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -157,6 +157,13 @@ namespace MemoryManager
used_mem += ARCH_PAGE_SIZE; used_mem += ARCH_PAGE_SIZE;
free_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; return index * ARCH_PAGE_SIZE;
} }