I am developing a serverside Javascript application (using our own engine). Now I need to test the application until I get an out of memory error. In Java you can try/catch this error since there it is an exception. I could not try/catch it in Javascript. Is there any way to continue execution after the error is thrown?
Asked
Active
Viewed 3,141 times
3
-
I don't think so. Honestly, catching it in Java is asking for trouble too. When you're Out of Memory how do you intend to recover? – Elliott Frisch Aug 30 '14 at 11:29
-
Well Java does it for you so I thought there might be a way in Javascript ;-) but I suspected there is none. – eclipse Aug 30 '14 at 11:31
-
3Java [does not recover](http://stackoverflow.com/q/37335/2970947) from OOM for you. There's a reason it's a runtime error. – Elliott Frisch Aug 30 '14 at 11:33
-
Since your make your own engine, you can just throw the error on allocations, but the problem is that, handling it in try/catch might cause further allocations and your app will crash eventually. – Farid Nouri Neshat Aug 30 '14 at 11:34
-
1And the point is not to recover but rather output something afterwards. But I guess I can output beforehand and just wait till it fails! – eclipse Aug 30 '14 at 11:34
-
@eclipse Will this [nodejs out of memory](http://stackoverflow.com/questions/7357339/nodejs-out-of-memory) help? – shrekuu Aug 30 '14 at 11:40