title: How to solve memory leak problem when using opencv.js?
body: <p>I am using opencv.js to process images upload by user but met memory leak problem. I have tried the same code as opencv.js document but still met the problem.</p>
  <p>Here is my code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>let land = window.cv.imread("land-show");
  let mask = window.cv.imread("mask-show");
  let sky = window.cv.imread("sky-show");
  
  window.cv.threshold(
    mask,
    mask,
    parseFloat(trackBarValue),
    parseFloat(trackBarValue),
    window.cv.THRESH_TRUNC
  );
  
  let mat = mask.clone();
  
  window.cv.resize(sky, sky, land.size());
  window.cv.resize(mask, mask, land.size());
  sky.convertTo(sky, window.cv.CV_64FC4, 1);
  mask.convertTo(mask, window.cv.CV_64FC4, 1 / 255);
  land.convertTo(land, window.cv.CV_64FC4, 1);
  sky = sky.mul(mask, 1);
  
  window.cv.cvtColor(mat, mat, window.cv.COLOR_RGBA2RGB, 0);
  window.cv.bitwise_not(mat, mat)
  window.cv.cvtColor(mat, mat, window.cv.COLOR_RGB2RGBA, 0);
  mat.convertTo(mat, window.cv.CV_64FC4, 1 / 255);
  
  land = land.mul(mat, 1);
  window.cv.add(land, sky, land);
  land.convertTo(land, window.cv.CV_8UC4, 1);
  window.cv.imshow("output", land);
  land.delete();
  mask.delete();
  sky.delete();
  mat.delete();</code></pre>
  </div>
  </div>
  </p>
  <p>I have use delete() API to free memory used by Mat objects and tried to use some temp object for convert APIs, but the problem still there. How can I solve it?</p>
  <p>Memory reach to maximum:
  <a href="https://i.stack.imgur.com/hKdyY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hKdyY.png" alt="enter image description here" /></a></p>