Main modules can be a lot larger than regular programs, since we don't eliminate dead code - we assume another module loaded later may want to call it. So any library that is linked in will remain in full size, and we include libc by default (even with an empty main) as well as all JS libraries.
Another factor here is that your command does not optimize. With -Os for example, the output is 1/3 smaller. But the bigger factor is it being a main module. Without that flag, the resulting files are 74x smaller. On Sun, Sep 2, 2018 at 6:36 AM Al Izi <[email protected]> wrote: > I've got a blank cpp module (just empty main and no libraries are > included) compiled as a "main module": > > em++ dummy.cc -o dummy.js -s MODULARIZE=1 -s INCLUDE_FULL_LIBRARY=0 -s > WASM=1 -s ASSERTIONS=0 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_MEMORY=1MB -s > TOTAL_STACK=128KB -std=c++11 -s MAIN_MODULE=1 > > This module is loaded by node > > console.log(process.memoryUsage()) > Module = require('./dummy'); > Module({}).then((m) => { > console.log(process.memoryUsage()) > }); > > Memory usage of node itself (as shown by activity monitor) is 7MB. With > the above module loaded it becomes almost 40MB. Is this expected? Is there > any way to decrease the amount of using memory? > > > Btw, the output is: > { rss: 19574784, > heapTotal: 6062080, > heapUsed: 3663952, > external: 8272 } > > { rss: 47509504, > heapTotal: 19042304, > heapUsed: 15156120, > external: 3422273 } > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
