ml5-library icon indicating copy to clipboard operation
ml5-library copied to clipboard

Possible memory leak in charRNN?

Open hlp-pls opened this issue 5 years ago • 2 comments

Dear ml5 community, I think there maybe a memory leak with charRNN in ml5js. I was making an example that uses stateful prediction with a custom-trained model. I followed the tutorial below provided by paperspace to train the model. https://blog.paperspace.com/training-an-lstm-and-using-the-model-in-ml5-js/ I'm quite new to ml5js, and the problem may exclusively be in my code, but memory leak is happening when text is being generated for some time.

→ Step 1: Describe the issue šŸ“

I think I found a possible memory leak while using charRNN.

→ Step 2: Screenshots or Relevant Documentation šŸ–¼

I looked at the code that I think the charRNN library is using, and I don't think it is releasing tensors after use. Maybe there is no need to? I'm not sure. Below is the link to the code. https://github.com/ml5js/ml5-library/blob/development/src/CharRNN/index.js

→ Step 3: Share an example of the issue šŸ¦„

The example below is a demonstration of this issue. The example is using stateful prediction. The model is trained with korean text, and therefore needs korean text as input. It takes some time for the browser to crash. example link: https://hlp-pls.github.io/generate-text-file/ code repository link: https://github.com/hlp-pls/generate-text-file

→ Describe your setup šŸ¦„

Here's some helpful information about my setup...

  • Web browser & version: Chrome 83.0.4103.116
  • Operating System: macOS 10.14.6
  • ml5 version you're using: v0.5.0

hlp-pls avatar Jun 29 '20 06:06 hlp-pls

į„‰į…³į„į…³į„…į…µį†«į„‰į…£į†ŗ 2020-06-29 į„‹į…©į„’į…® 4 03 16 This is the error message that the console shows!

hlp-pls avatar Jun 29 '20 07:06 hlp-pls

Great catch! You are right — there are definitely some tensors which are not getting disposed. I’m adding this one to my todo list.

lindapaiste avatar Apr 20 '22 05:04 lindapaiste