LumiGuide / haskell-opencv

Haskell binding to OpenCV-3.x
Other
154 stars 44 forks source link

Add scoped Mat conversion functions allowing prompt memory freeing. #136

Closed nh2 closed 5 years ago

nh2 commented 5 years ago

See commit message for details.

In my application where I call out to CUDA while creating Mats, using withHMatAsMat instead of hMatToMat changes memory usage from linearly increasing (depending on whether I force GC) up to 20 GB to 250 MB constant memory usage.

Based on #135, please merge that one first.

nh2 commented 5 years ago

This is the cherry-pick / adjustment of my branch withHMatAsMat-opencv-0.0.2.1 for master.

basvandijk commented 5 years ago

@nh2 thanks!

@roelvandijk let's if we can rewrite mkFinalizer in terms of funPtr or maybe we can remove it and use funPtr directly inline (like we now do with Mats) which saves a top-level declaration.

basvandijk commented 5 years ago

@roelvandijk even better would be to rewrite objFromPtr in terms of funPtr.