aces / brainbrowser

Web-based visualization tools for neurological data.
https://brainbrowser.cbrain.mcgill.ca/
GNU Affero General Public License v3.0
351 stars 122 forks source link

Memory leaks #338

Open wpmed92 opened 7 years ago

wpmed92 commented 7 years ago

Hello!

I really like your library I use it one of my projects. I need really fast garbage collection because they'll use my application in a clinical environment, but the extensive usage of callbacks in your lib results in slow GC, and in some objects not being collected at all. I found that after calling viewer.clearVolumes() the TypedArrays allocated are actually never freed, which results in out of memory error when loading and reloading lot of files. Also in nifti1 the loadFromFile's callback is not always collected (so the arraybuffer 'sticks' in the GC chain). In Mozilla's Dominators view I see it being collected when loading file for the first time. But when I load a file again, the callback stays on the heap and is never collected. (Maybe it would've been collected but once I tested it wasn't collected in like an hour or so). The latter is pretty strange though. I attached screenshots, but you can test it on your machine.

  1. arrayBuffer on heap before GC kicks in gc_debug_1
  2. arrayBuffer collected gc_debug_1_freed
  3. a new file loaded (viewer.clearVolumes not freeing up typedarrays and arraybuffer from file loading sticks on heap as well) gc_debug_2_not_collected
rdvincent commented 7 years ago

Thanks for the report. I'll try to look into this.

wpmed92 commented 7 years ago

Thank you. Looks like the ArrayBuffer somehow survives in createNifti1Data? Not sure though.

wpmed92 commented 7 years ago

"But when I load a file again, the callback stays on the heap and is never collected. " this one seems to be firefox specific, not present in chrome. viewer.clearVolumes() bug is present in both

gregorybolkenstijn commented 5 years ago

I'm having similar issues. Any word about progress on this?

lblewis commented 5 years ago

It is my understanding (someone please correct me if I am wrong) that @rdvincent is occupied with other work for the foreseeable future, and @natacha-beck is on maternity leave through the summer. Please chime in if anyone else in working on this...?