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('')
console.log('If you are having an error while trying to run this Client, consider this:')
fatalErrorHelp()
fatalErrorHelp()
return
}
// 9808us Code -- Proposal to improve RAM issues
const os = require("os")
let totalRAM = os.totalmem() // Get total ram installed
totalRAM = totalRAM / 1024 / 1024
const OS = require("os")
let totalRAM = OS.totalmem() // Get total ram installed
totalRAM = totalRAM / 1024 / 1024
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("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('OPTIONS ACCEPTED:')
console.log('')
let optionsAccepted = 0
let options = {
execArgv: [maxOldSpaceSize],
stdio: 'inherit'
}
if (process.argv.includes("minMemo")) {
options = {
stdio: 'inherit'
}
optionsAccepted++
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))
}
console.log('minMemo ............................ Running with Minimun Required Memory.')
}
if (process.argv.includes("noBrowser")) {
optionsAccepted++
console.log('noBrowser .......................... Running without User Interface')
console.log('noBrowser .......................... Running without User Interface.')
}
if (optionsAccepted === 0) {
console.log('none ............................... Running without any command line options')
console.log('')
console.log('none ............................... Running without any command line options.')
}
console.log('')
console.log('')
try {
@@ -86,7 +88,7 @@ try {
console.log('Fail to create Client Process.')
console.log('')
fatalErrorHelp()
fatalErrorHelp()
}
function fatalErrorHelp() {