If you get Execution Interrupted then something would have stopped working halfway though. It silently deletes history before complaining about low memory.
Low free heap wouldn't have caused that error.
My guess is that res.end(page); is what's causing the problem - as the page is pretty big, and is just being appended to the output buffer, you're basically doubling your memory usage when a page is requested.
As such, even if you put the page into flash memory this might help for now, but you'll still hit this problem if you make the page much bigger.
There's some example code on the internet page showing how you can use the drain event to supply data one bit at a time, and you could do that - serving out a few hundred bytes at a time.
But for you, the simplest solution would actually be to have 2 files - one script and one HTML. You then include the JS from the HTML file, and serve up the 2 different files in onPageRequest.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
If you get
Execution Interrupted
then something would have stopped working halfway though. It silently deletes history before complaining about low memory.Low free heap wouldn't have caused that error.
My guess is that
res.end(page);
is what's causing the problem - as the page is pretty big, and is just being appended to the output buffer, you're basically doubling your memory usage when a page is requested.As such, even if you put the page into flash memory this might help for now, but you'll still hit this problem if you make the page much bigger.
There's some example code on the internet page showing how you can use the
drain
event to supply data one bit at a time, and you could do that - serving out a few hundred bytes at a time.But for you, the simplest solution would actually be to have 2 files - one script and one HTML. You then include the JS from the HTML file, and serve up the 2 different files in
onPageRequest
.