Check at startup whether the requested memory is available
This issue was reported by @papillon
On a PCO Edge Linux computer, the GPFS client is configured to reserve 16GB (25% of the total memory). By default Lima try to allocate 70% of the physical memory (without checking the memory usage by other process).
Copy pasting from StackOverflow (the best design pattern ever):
#include "sys/types.h"
#include "sys/sysinfo.h"
struct sysinfo memInfo;
sysinfo (&memInfo);
Total Physical Memory (RAM)
long long totalPhysMem = memInfo.totalram;
//Multiply in next statement to avoid int overflow on right hand side...
totalPhysMem *= memInfo.mem_unit;
Physical Memory currently used
long long physMemUsed = memInfo.totalram - memInfo.freeram;
//Multiply in next statement to avoid int overflow on right hand side...
physMemUsed *= memInfo.mem_unit;