mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 04:35:46 +01:00
More work on NSJS memory leak fix
This commit is contained in:
parent
054cb63227
commit
bf5b3c371e
32
dist/engine.bundle.js
vendored
32
dist/engine.bundle.js
vendored
@ -26512,6 +26512,11 @@ function loadAllRunningScripts() {
|
||||
//Reset each server's RAM usage to 0
|
||||
server.ramUsed = 0;
|
||||
|
||||
//Reset modules on all scripts
|
||||
for (var i = 0; i < server.scripts.length; ++i) {
|
||||
server.scripts[i].module = "";
|
||||
}
|
||||
|
||||
for (var j = 0; j < server.runningScripts.length; ++j) {
|
||||
count++;
|
||||
server.runningScripts[j].scriptRef.module = "";
|
||||
@ -63659,9 +63664,10 @@ async function executeJSScript(script, scripts = [], workerScript) {
|
||||
console.log("loadedModule:");
|
||||
console.log(loadedModule);
|
||||
let constructedModule = await ConstructModule(loadedModule, ns);
|
||||
constructedModule = await constructedModule();
|
||||
console.log("constructedModule: ");
|
||||
console.log(constructedModule);
|
||||
return await constructedModule.main();
|
||||
return constructedModule.main();
|
||||
} finally {
|
||||
// Revoke the generated URLs
|
||||
if (urlStack != null) {
|
||||
@ -63670,14 +63676,24 @@ async function executeJSScript(script, scripts = [], workerScript) {
|
||||
};
|
||||
}
|
||||
|
||||
async function ConstructModule(module, ns) {
|
||||
for (var prop in ns) {
|
||||
eval("var " + prop + " = ns[\"" + prop + "\"];");
|
||||
function ConstructModule(module, ns) {
|
||||
function mod() {
|
||||
/*
|
||||
for (var fn in ns) {
|
||||
let fooName = fn.toString();
|
||||
var evalStatement = "var " + fooName + " = ns[\"" + fooName + "\"];"
|
||||
console.log(evalStatement);
|
||||
eval(evalStatement);
|
||||
console.log(ns[fooName]);
|
||||
console.log("Setting " + fooName + " in ConstructModule()");
|
||||
console.log(fooName);
|
||||
console.log(" ");
|
||||
}*/
|
||||
var newModule = Object.create(module);
|
||||
newModule.tprint = ns.tprint;
|
||||
return newModule;
|
||||
}
|
||||
async function mod() {
|
||||
return module;
|
||||
}
|
||||
return mod();
|
||||
return mod;
|
||||
}
|
||||
|
||||
// Gets a stack of blob urls, the top/right-most element being
|
||||
|
32
dist/tests.bundle.js
vendored
32
dist/tests.bundle.js
vendored
@ -26512,6 +26512,11 @@ function loadAllRunningScripts() {
|
||||
//Reset each server's RAM usage to 0
|
||||
server.ramUsed = 0;
|
||||
|
||||
//Reset modules on all scripts
|
||||
for (var i = 0; i < server.scripts.length; ++i) {
|
||||
server.scripts[i].module = "";
|
||||
}
|
||||
|
||||
for (var j = 0; j < server.runningScripts.length; ++j) {
|
||||
count++;
|
||||
server.runningScripts[j].scriptRef.module = "";
|
||||
@ -63700,9 +63705,10 @@ async function executeJSScript(script, scripts = [], workerScript) {
|
||||
console.log("loadedModule:");
|
||||
console.log(loadedModule);
|
||||
let constructedModule = await ConstructModule(loadedModule, ns);
|
||||
constructedModule = await constructedModule();
|
||||
console.log("constructedModule: ");
|
||||
console.log(constructedModule);
|
||||
return await constructedModule.main();
|
||||
return constructedModule.main();
|
||||
} finally {
|
||||
// Revoke the generated URLs
|
||||
if (urlStack != null) {
|
||||
@ -63711,14 +63717,24 @@ async function executeJSScript(script, scripts = [], workerScript) {
|
||||
};
|
||||
}
|
||||
|
||||
async function ConstructModule(module, ns) {
|
||||
for (var prop in ns) {
|
||||
eval("var " + prop + " = ns[\"" + prop + "\"];");
|
||||
function ConstructModule(module, ns) {
|
||||
function mod() {
|
||||
/*
|
||||
for (var fn in ns) {
|
||||
let fooName = fn.toString();
|
||||
var evalStatement = "var " + fooName + " = ns[\"" + fooName + "\"];"
|
||||
console.log(evalStatement);
|
||||
eval(evalStatement);
|
||||
console.log(ns[fooName]);
|
||||
console.log("Setting " + fooName + " in ConstructModule()");
|
||||
console.log(fooName);
|
||||
console.log(" ");
|
||||
}*/
|
||||
var newModule = Object.create(module);
|
||||
newModule.tprint = ns.tprint;
|
||||
return newModule;
|
||||
}
|
||||
async function mod() {
|
||||
return module;
|
||||
}
|
||||
return mod();
|
||||
return mod;
|
||||
}
|
||||
|
||||
// Gets a stack of blob urls, the top/right-most element being
|
||||
|
@ -44,9 +44,10 @@ export async function executeJSScript(script, scripts = [], workerScript) {
|
||||
console.log("loadedModule:");
|
||||
console.log(loadedModule);
|
||||
let constructedModule = await ConstructModule(loadedModule, ns);
|
||||
constructedModule = await constructedModule();
|
||||
console.log("constructedModule: ");
|
||||
console.log(constructedModule);
|
||||
return await constructedModule.main();
|
||||
return constructedModule.main();
|
||||
} finally {
|
||||
// Revoke the generated URLs
|
||||
if (urlStack != null) {
|
||||
@ -55,14 +56,24 @@ export async function executeJSScript(script, scripts = [], workerScript) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function ConstructModule(module, ns) {
|
||||
for (var prop in ns) {
|
||||
eval("var " + prop + " = ns[\"" + prop + "\"];");
|
||||
export function ConstructModule(module, ns) {
|
||||
function mod() {
|
||||
/*
|
||||
for (var fn in ns) {
|
||||
let fooName = fn.toString();
|
||||
var evalStatement = "var " + fooName + " = ns[\"" + fooName + "\"];"
|
||||
console.log(evalStatement);
|
||||
eval(evalStatement);
|
||||
console.log(ns[fooName]);
|
||||
console.log("Setting " + fooName + " in ConstructModule()");
|
||||
console.log(fooName);
|
||||
console.log(" ");
|
||||
}*/
|
||||
var newModule = Object.create(module);
|
||||
newModule.tprint = ns.tprint;
|
||||
return newModule;
|
||||
}
|
||||
async function mod() {
|
||||
return module;
|
||||
}
|
||||
return mod();
|
||||
return mod;
|
||||
}
|
||||
|
||||
// Gets a stack of blob urls, the top/right-most element being
|
||||
|
@ -713,6 +713,11 @@ function loadAllRunningScripts() {
|
||||
//Reset each server's RAM usage to 0
|
||||
server.ramUsed = 0;
|
||||
|
||||
//Reset modules on all scripts
|
||||
for (var i = 0; i < server.scripts.length; ++i) {
|
||||
server.scripts[i].module = "";
|
||||
}
|
||||
|
||||
for (var j = 0; j < server.runningScripts.length; ++j) {
|
||||
count++;
|
||||
server.runningScripts[j].scriptRef.module = "";
|
||||
|
Loading…
Reference in New Issue
Block a user