You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thanks for providing such a powerful library! I’m currently using glpk.js in a project and looking for some advice with a memory issue.
1. Context:
Using GLPK.js in a web application (React)
Each run involves solving 25 LP instances
Each instance has approximately 200 decision variables and 200 constraints
The application runs perfectly for the first 4 runs
Everytime, on the 5th run, I encounter the following error:
ERROR Uncaught RangeError: WebAssembly.Instance(): Out of memory: Cannot allocate Wasm memory for new instance at handleError (http://localhost:3000/static/js/bundle.js:394110:58) at http://localhost:3000/static/js/bundle.js:394129:7
2. Current Approach: (not working)
I tried to assign the problem instance to null after solving, but it did not work. Here is how my code looks like in general:
import GLPK from 'glpk.js';
export const runOP = async ({ inputs }) => {
// Extract input values
(details skipped)
// Load GLPK
let glpk = await GLPK();
// Prepare the model
let lp = {
name: 'MyOP',
objective: {
direction: glpk.GLP_MIN,
name: 'cost',
vars: []
},
subjectTo: [],
vars: {}
};
// Add variables
(details skipped)
// Solve the problem
try {
const result = await glpk.solve(lp);
// Extract results
(details skipped)
return {
status: status,
optimalCost: optimalCost,
};
} catch (error) {
console.error('Error solving LP:', error);
return {
status: 'Error',
optimalCost: null,
};
} finally {
// Try to clean up, but did not work
lp = null;
glpk = null;
}
};
3. Question:
Do you have any suggestions for managing memory in this scenario to avoid the out-of-memory error?
Hi @zuzhaoye, I am afraid there is no team - just me and my ~10 tiny fingers. If you could put together a working example with a sufficiently large LP then I can give it a try. Maye take an example from here https://github.com/Ivordir/YALPS?
Hi GLPK team,
First, thanks for providing such a powerful library! I’m currently using glpk.js in a project and looking for some advice with a memory issue.
1. Context:
ERROR Uncaught RangeError: WebAssembly.Instance(): Out of memory: Cannot allocate Wasm memory for new instance at handleError (http://localhost:3000/static/js/bundle.js:394110:58) at http://localhost:3000/static/js/bundle.js:394129:7
2. Current Approach: (not working)
I tried to assign the problem instance to null after solving, but it did not work. Here is how my code looks like in general:
3. Question:
Do you have any suggestions for managing memory in this scenario to avoid the out-of-memory error?
4. Additional Information:
Browser: Chrome, 128.0.6613.138
GLPK.js version: 4.0.2
Node.js version: v20.15.1
The text was updated successfully, but these errors were encountered: