Comments (8)
It also happens to the browser version.
I am not familiar with Emscripten. According to emscripten-core/emscripten#6747 (comment), it seems we need to have some special ways to create arrays to avoid memory growth.
The comments in that issue are very hard to understand 😵💫
Here is a demo for this error.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Demo</title>
<script type="module">
import GLPK from './index.js';
(async () => {
const glpk = await GLPK();
const modelURL = 'https://gist.githubusercontent.com/xiaohk/73fd07e4d9b35ac572cb9a927db45462/raw/71b83b13d1601c7ed6c73194983157eeef534123/model.json';
let result = await fetch(modelURL);
let modelData = await result.json();
// Error happens when i = 13
for (let i = 0; i < 15; i++) {
console.log(i);
let pResult = await glpk.solve(modelData);
console.log(pResult);
}
document.querySelector('#output').innerHTML = `
Hello World!
`;
})()
</script>
</head>
<body>
<textarea id="output" style="width: 800px; height: 500px" readonly></textarea>
</body>
</html>
from glpk.js.
Hi @xiaohk, thanks for the example. I have never had a memory issue even with large LPs so I will definitely try to fix this one if I can find the issue. Maybe there were changes in the current emscripten regarding memory handling that I am was not aware of when I made the new release.
from glpk.js.
Hi @jvail, thank you so much for your quick reply! Really appreciate your continuing support and maintenance! I am not familiar with C or C++, but I will also help as I can. Based on emscripten-core/emscripten#6747 (comment), the following array initialization might be worth looking into.
Lines 96 to 104 in eabefee
from glpk.js.
Hi, yes, you are right. I can reproduce it and it happens in line 98. What I do not understand why it needs grow memory if you run the same LP over and over. Maybe there is a more severe issue with freeing memory. I'll debug it but it might take some time. Can I use your LP file as a test case later?
from glpk.js.
Hi, yes, you are right. I can reproduce it and it happens in line 98. What I do not understand why it needs grow memory if you run the same LP over and over. Maybe there is a more severe issue with freeing memory. I'll debug it but it might take some time. Can I use your LP file as a test case later?
Sure! Thank you 🙌
from glpk.js.
Hi @xiaohk, I am still puzzled why this issue appears now but it seems to be gone now. Apparently I made a big mistake and did not free the memory properly - so, thanks for reporting the bug. Would you like to give it a try and checkout the dev branch to test if it works for you now?
from glpk.js.
Hi @xiaohk, I am still puzzled why this issue appears now but it seems to be gone now. Apparently I made a big mistake and did not free the memory properly - so, thanks for reporting the bug. Would you like to give it a try and checkout the dev branch to test if it works for you now?
Amazing! 680de13 is working for me now. Thank you so much for your quick reply and fix!
from glpk.js.
@xiaohk Sure, no problem, thanks for reporting & testing 👍
from glpk.js.
Related Issues (20)
- Erratic performance on Firefox HOT 6
- v4 API HOT 1
- Add travis build HOT 1
- Allow setting "shift" for objective HOT 2
- Update to GLPK 5 HOT 5
- assignment to undeclared variable P HOT 2
- Variable are lower bounded at 0 ??? HOT 17
- Possible to use CBC instead of GLPK? HOT 4
- Constraint violation in solution? HOT 3
- glpk v5.0 HOT 1
- Problem with very simple model (square 2x2) HOT 4
- GLPK.GLP_FR potentially undefined (also: allowing non-negative variables) HOT 3
- Using GLPK() in TypeScript results in 'This expression is not callable' HOT 4
- compile glpk 5.0 error HOT 2
- Solving GLPK through LP format HOT 1
- Enhancement: also provide constraint result values HOT 2
- Need help modelling a simple(?) battery charge problem HOT 3
- Types do not include `Promise<>` HOT 1
- "Uncaught ReferenceError: glpk is not defined" even after local loading HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glpk.js.