read ratio from swap-ratio

This commit is contained in:
Girish Ramakrishnan
2021-01-20 20:05:39 -08:00
parent 4d482d11ee
commit 7660e90d51
2 changed files with 9 additions and 2 deletions

View File

@@ -166,7 +166,12 @@ function getMemory(callback) {
}
function getMemoryAllocation(limit) {
const pc = os.totalmem() / (os.totalmem() + getSwapSize());
const ratio = Math.round(pc * 10) / 10; // a simple ratio
let ratio = parseFloat(safe.fs.readFileSync(paths.SWAP_RATIO_FILE, 'utf8'), 10);
if (!ratio) {
const pc = os.totalmem() / (os.totalmem() + getSwapSize());
ratio = Math.round(pc * 10) / 10; // a simple ratio
}
return Math.round(Math.round(limit * ratio) / 1048576) * 1048576; // nearest MB
}