brainbrowser icon indicating copy to clipboard operation
brainbrowser copied to clipboard

Memory leaks

Open wpmed92 opened this issue 8 years ago • 5 comments

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

wpmed92 avatar Sep 07 '17 12:09 wpmed92

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

rdvincent avatar Sep 07 '17 12:09 rdvincent

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

wpmed92 avatar Sep 07 '17 13:09 wpmed92

"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

wpmed92 avatar Sep 08 '17 07:09 wpmed92

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

gregorybolkenstijn avatar Nov 09 '18 08:11 gregorybolkenstijn

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...?

lblewis avatar Nov 09 '18 14:11 lblewis