Ask Your Question

Fabek's profile - activity

2016-05-25 08:31:20 -0600 received badge  Editor (source)
2016-05-24 22:19:36 -0600 asked a question Node.js + OpenCV readImage() memory leaks

I have a problem with memory leaks (about 3-4MB each even cycle of this code) on node.js + opencv. I think readImage() method causes that memory issue.

How to free unused memory? I've tried release() function, but it causes segmentation error.

Is anyone already encountered this problem?

Please help. I'm stucked.

Unfortunatelly, without results...

download = wget.download(src, path + filename, options);

download.on('end', function(output) {

  cv.readImage(path + filename, function(err, im) {
    if (err) throw err;
    if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');

    im.detectObject('data/cascade.xml', {}, function(err, cars) {
      if (err) throw err;

      for (var i = 0; i < cars.length; i++) {
        car = cars[i];
        im.rectangle([car.x, car.y], [car.width, car.height], [0, 255, 0], 2);
      }

      im.save(path + '_' + filename);

    });

  });

});

SOLVED: nano /etc/crontab and add line:

* * * * * root sync; sync; sync; echo 3 >/proc/sys/vm/drop_caches;

It isn't beautiful, but it works.