xuri / excelize-wasm

A WebAssembly build of the Go Excelize library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
180 stars 32 forks source link

memory running out #10

Open spearmootz opened 1 year ago

spearmootz commented 1 year ago

hello,

i am running node with 4GB of memory.

when i create an excel containing around 64k records with 58 columns of uuids i run out of memory.

i tried to play with the importObject and added mem, and memory into various keys but it didnt work :( otherwise i would be making a PR

exports: {
    mem: new WebAssembly.Memory({ initial: 100, maximum: 62500, shared: true }),
    memory: new WebAssembly.Memory({
      initial: 100,
      maximum: 62500,
      shared: true,
    }),
  },
  env: {
    memory: new WebAssembly.Memory({
      initial: 100,
      maximum: 62500,
      shared: true,
    }),
    mem: new WebAssembly.Memory({ initial: 100, maximum: 62500, shared: true }),
  },
  js: {
    mem: new WebAssembly.Memory({ initial: 100, maximum: 62500, shared: true }),
    memory: new WebAssembly.Memory({
      initial: 100,
      maximum: 62500,
      shared: true,
    }),
  },
  go: {
    memory: new WebAssembly.Memory({
      initial: 100,
      maximum: 62500,
      shared: true,
    }),
    mem: new WebAssembly.Memory({ initial: 100, maximum: 62500, shared: true }),
xuri commented 1 year ago

Thanks for your feedback. I will investigate this problem recently.

spearmootz commented 1 year ago

@xuri i tried a lot of things.

i also tried to do

i.instance.exports.mem.grow(65000)

and that made it a ton faster, i assume because it had less memory grow events per say. but it reaches the exact same point. now that point is way less than 4GB (which is the maximum memory any wasm program can take at this time since its 32 bit). based on my intuition and what i read, i saw that for example when you compile rust to wasm you can specify to wasm that i can take more space. i researched how to do this in go but i did not find the answer. i hope this helps :(

spearmootz commented 1 year ago

@xuri for reference https://github.com/rustwasm/wasm-bindgen/issues/2498#issuecomment-801494135