Ask Your Question

Opencv.js: Getting (index):413 Uncaught (in promise) abort("OOM"). Build with -s ASSERTIONS=1 for more info.

asked 2019-09-18 21:40:05 -0500

vasanthahr gravatar image

updated 2019-09-18 21:43:04 -0500


I am getting this error from opencvjs and line number: 24 (we build the opencv.js as mentioned in Opencv document).

Could you please help to resolve this issue. Is there any way to catch this "OOM" and resume the execution smoother.

I used cv.calcOpticalFlowPyrLK(oldGray, frameGray, p0, p1, st, err, winSize, maxLevel, criteria); this code in my javascript, and handled this function insdie TRY and CATCH, but still getting OOM abort error as attached screenshot.

Below code runs well for 1 to 2 minutes and then start throwing OOM abort, so couldn't call any function inside opencvjs.

(For reference: )

//some code written here, executes for few mins and then getting this OOM abort error

cv.calcOpticalFlowPyrLK(oldGray, frameGray, p0, p1, st, err, winSize, maxLevel, criteria);

}catch (err) {
        console.log("Handle error===",err);


edit retag flag offensive close merge delete


I had a similar problem, my code written in JS was running for 1-2 mins (time depended on the device) and then suddenly crashing. I was using findContours. And I couldn't find the exact reason for a while. Then I found that the reason is that I don't clean memory. OpenCV uses very large matrices and you need to manually delete them after they become useless. Look at this example

const edged = new cv.Mat();
cv.Canny(dilated, edged, 60, 255);


So the general advice is to delete variables and use pure functions. For more details please provide your code

Lucy8 gravatar imageLucy8 ( 2019-09-23 09:00:37 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-09-27 22:20:16 -0500

vasanthahr gravatar image

Thanks, yes variable.delete() would help to solve this issue.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-09-18 21:40:05 -0500

Seen: 526 times

Last updated: Sep 18 '19