-
Notifications
You must be signed in to change notification settings - Fork 26
Error with malloc and memory limit #521
Description
HelloI
I am posting here since it could be useful for others too.
(edit: sorry, after submitting, I am realising this message should go to the discussion board)
have received a new version of the model and I found a "random" error related with the outputs.
The model is generated correctly but when I run it I find this error:
After removing some variables form the output.csv file I realized that the problem was not caused by any of them but by having too many. I managed to add the -S ASSERTIONS=1 to the wasm plugin:
wasmPlugin({
emccArgs: [
"-Wall", "-Os ",
"-sSTRICT=1 ",
"-sMALLOC=emmalloc",
"-sFILESYSTEM=0 ",
"-sMODULARIZE=1 ",
"-sSINGLE_FILE=1 ",
"-sEXPORT_ES6=1 ",
"-sUSE_ES6_IMPORT_META=0 ",
"-sENVIRONMENT='web,webview,worker' ",
"-sEXPORTED_FUNCTIONS='_malloc','_free','_getInitialTime','_getFinalTime','_getSaveper','_setLookup','_runModelWithBuffers']",
"-sEXPORTED_RUNTIME_METHODS=['cwrap']",
"-sASSERTIONS=1"] }),(note: I recommend including an example of this in the documentation since I didn't know that -s params don't have a space between "-s XXXXPARAMXXX" I can add it if you want)
Which, as suspected, is due to excess memory consumption.
Adding: -sINITIAL_MEMORY=32MB,or -sALLOW_MEMORY_GROWTH=1
seems to fix the problem.
What do you recommend? Do you think we can get into trouble by using 32MB? It doesn't seem like a lot for an application but I am not familiar with WASM limitations.
Rgds

