Bitburner

Bitburner

View Stats:
AlmightyMiau Dec 24, 2022 @ 12:34am
Need help with "RAM USAGE ERROR"
getting this error:

RAM USAGE ERROR poison.script@attack (PID - 974) getServerSecurityLevel: Dynamic RAM usage calculated to be greater than initial RAM usage. This is probably because you somehow circumvented the static RAM calculation. Threads: 9000 Dynamic RAM Usage: 1.90GB per thread Static RAM Usage: 1.85GB per thread One of these could be the reason: * Using eval() to get a reference to a ns function const myScan = eval('ns.scan'); * Using map access to do the same const myScan = ns['scan']; Sorry :(

The code that is running is:

var target = args[0]; while (true) { var moneyThresh = getServerMaxMoney(target) * 0.90; var securityThresh = getServerMinSecurityLevel(target) + 3; if ((getServerSecurityLevel(target)) > (securityThresh)) { weaken(target); } else { grow(target); } }
< >
Showing 1-1 of 1 comments
The system gives commonly RAM errors on syntax errors. Just a missing tic or parantheses can cause such an error. Maybe you should use 'strict mode'. Then you get really every f*ckin' error.

BTW: Better use const and let for declaration, not var. ;-)

/** * @param {NS} ns * ns.args string The hostname of the target */ export async function main(ns) { 'use strict'; const target = (ns.args.length > 0 && ns.args[0] === 'string') ? ns.args[0] : undefined; const moneyThresh = ns.getServerMaxMoney(target) * 0.90; const securityThresh = ns.getServerMinSecurityLevel(target) + 3; if (target) { while (true) { if ((ns.getServerSecurityLevel(target)) > (securityThresh)) { await ns.weaken(target); } else { await ns.grow(target); } } } else { ns.tprintf('ERROR :: No target passed. Exiting !!!', ''); } }
Last edited by .m0rphisto; Jul 6, 2023 @ 5:36am
< >
Showing 1-1 of 1 comments
Per page: 1530 50