mcneel / rhino3dm

Libraries based on OpenNURBS with a RhinoCommon style
MIT License
574 stars 135 forks source link

Cannot enlarge memory #512

Open harrycollin opened 1 year ago

harrycollin commented 1 year ago

I'm working with rhino3dm JS in Node with the wasm module. I'm trying to work with a 1gb file but have been getting this error from the wasm.

Cannot enlarge memory, asked to go up to 2830614528 bytes, but the limit is 2147483648 bytes!

Is there a way around this?

fraguada commented 1 year ago

Currently the maximum memory is set to the default heap size of 2GB (the 2147483648). We can try to increase this in subsequent builds but need to study the consequences. I'll try to compile something with 4GB ceiling and link the result here for you to try.

harrycollin commented 1 year ago

Thank you @fraguada!

fraguada commented 1 year ago

@harrycollin please check this build (available for 15 days): https://github.com/mcneel/rhino3dm/suites/11870654063/artifacts/620806777

I've raised the maximum memory heap to 4GB from the default 2GB. I'd be curious to know if this makes any difference in your case.

harrycollin commented 1 year ago

@fraguada Thank you! I just tested this but the module is still requesting more memory beyond the limit :/ Which options do you think I have for this? I'd be interested to see a MEMORY64 build of the wasm in the future for these big models.

fraguada commented 1 year ago

I'll take a look.

fraguada commented 1 year ago

Not sure what is needed, but a MEMORY64 build doesn't seem to be building. Where are you using the library? Seems MEMORY64 support across browsers is only on nightly builds and node with special flags.

harrycollin commented 1 year ago

I would be using the library server-side with Node, so the browser support isn't a concern for me. It can be enabled with the --experimental-wasm-memory64 flag.

fraguada commented 8 months ago

@harrycollin after our meeting in Barcelona I think I will add nodejs as a platform and build it with the --experimental-wasm-memory64 and see how that works for you. FWIW I have brought back the max memory in the js build.

harrycollin commented 8 months ago

Great to hear @fraguada! It was a pleasure discussing this with you. I'll test it as soon as it's ready :)

fraguada commented 8 months ago

Note, getting errors on compilation:


[ 69%] Linking CXX executable rhino3dm.js
em++: warning: -sMEMORY64 is still experimental. Many features may not work. [-Wexperimental]
cache:INFO: generating system asset: symbol_lists/4e0764ba4c2b370d82d769cdd9dca3fefe4949cb.txt... (this will be cached in "/home/ubuntu/emsdk/upstream/emscripten/cache/symbol_lists/4e0764ba4c2b370d82d769cdd9dca3fefe4949cb.txt" for subsequent builds)
cache:INFO:  - ok
wasm-ld: error: CMakeFiles/rhino3dm.dir/lib/opennurbs/zlib/adler32.c.o: wasm32 object file can't be linked in wasm64 mode
em++: error: '/home/ubuntu/emsdk/upstream/bin/wasm-ld @/tmp/emscripten_lwq1lfq1.rsp.utf-8' failed (returned 1)
make[2]: *** [CMakeFiles/rhino3dm.dir/build.make:5031: rhino3dm.js] Error 1
make[1]: *** [CMakeFiles/Makefile2:162: CMakeFiles/rhino3dm.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
emmake: error: 'make' failed (returned 2)
fraguada commented 4 months ago

TODO: Need to test this as Chrome has fixed a bug related to this, and it should be available in node

harrycollin commented 2 months ago

Hey @fraguada, is there any news on this? :)