Fine Tunning Memory Management

This commit is contained in:
Luis Fernando Molina committed 2021-01-26 18:58:45 +01:00
1 parent a3410e34bc
commit 29174307b1
1 file changed
+28 -26
+28 -26
View File
@@ -30,52 +30,54 @@ if (
console.log(' minMemo: Optional. Use it when your hardware has less than 8 Gb or memory.') console.log(' minMemo: Optional. Use it when your hardware has less than 8 Gb or memory.')
console.log('') console.log('')
console.log('If you are having an error while trying to run this Client, consider this:') console.log('If you are having an error while trying to run this Client, consider this:')
fatalErrorHelp() fatalErrorHelp()
return return
} }
const OS = require("os")
// 9808us Code -- Proposal to improve RAM issues let totalRAM = OS.totalmem() // Get total ram installed
const os = require("os") totalRAM = totalRAM / 1024 / 1024
let totalRAM = os.totalmem() // Get total ram installed
totalRAM = totalRAM / 1024 / 1024
let optimalRAM = totalRAM * 0.85 // Use 85% of installed RAM let optimalRAM = totalRAM * 0.85 // Use 85% of installed RAM
let maxOldSpaceSize = "--max-old-space-size="+(optimalRAM.toFixed(0)).toString() let maxOldSpaceSize = "--max-old-space-size=" + (optimalRAM.toFixed(0)).toString()
let options
console.log('') console.log('')
console.log("Total RAM istalled in this system is: " + totalRAM.toFixed(0)) // Print the result in MB console.log("Total RAM istalled in this system is ..... " + (totalRAM / 1024).toFixed(2) + " GB")
if (process.argv.includes("minMemo")) {
options = {
stdio: 'inherit'
}
console.log("Total RAM available for Superalgos is .... 512 MB")
} else {
options = {
execArgv: [maxOldSpaceSize],
stdio: 'inherit'
}
console.log("Total RAM available for Superalgos is .... " + (optimalRAM / 1024).toFixed(2) + " GB")
console.log('')
console.log('If you would like to enable less RAM than that, use the minMemo flag. Note: RAM will be allocated only if needed.')
}
console.log('') console.log('')
console.log('OPTIONS ACCEPTED:') console.log('OPTIONS ACCEPTED:')
console.log('') console.log('')
let optionsAccepted = 0 let optionsAccepted = 0
let options = {
execArgv: [maxOldSpaceSize],
stdio: 'inherit'
}
if (process.argv.includes("minMemo")) { if (process.argv.includes("minMemo")) {
options = {
stdio: 'inherit'
}
optionsAccepted++ optionsAccepted++
console.log('minMemo ............................ Running with Minimun Required Memory') console.log('minMemo ............................ Running with Minimun Required Memory.')
} else { }
console.log('no minMemo configured .............. Running with 85% of installed Memory')
console.log('will use ........................... --max-old-space-size=' + optimalRAM.toFixed(0))
}
if (process.argv.includes("noBrowser")) { if (process.argv.includes("noBrowser")) {
optionsAccepted++ optionsAccepted++
console.log('noBrowser .......................... Running without User Interface') console.log('noBrowser .......................... Running without User Interface.')
} }
if (optionsAccepted === 0) { if (optionsAccepted === 0) {
console.log('none ............................... Running without any command line options') console.log('none ............................... Running without any command line options.')
console.log('')
} }
console.log('')
console.log('') console.log('')
try { try {
@@ -86,7 +88,7 @@ try {
console.log('Fail to create Client Process.') console.log('Fail to create Client Process.')
console.log('') console.log('')
fatalErrorHelp() fatalErrorHelp()
} }
function fatalErrorHelp() { function fatalErrorHelp() {