-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Cv.Load<CvHaarClassifierCascade>()
returns an object that when disposed, will not release memory allocated, probably because IsEnabledDispose
is set to false.
The following code sample replicates and fixes the bug:
static void Main(string[] args)
{
for (var i = 0; i < 10000; i++)
{
//A potential b.ug in OpenCVSharp marks CvHaarClassifierCascade.IsEnabledDispose = false, preventing the IDispoable pattern from
//cleaning up the memory allocated when loading the face detection features
using (var res = Cv.Load<CvHaarClassifierCascade>("./haarcascade_frontalface_default.xml"))
{
//Calling this method cleans up the region of allocated memory correctly.
//Comment out these two lines to reproduce the memory leak.
var ptr = res.CvPtr;
NativeMethods.cvReleaseHaarClassifierCascade(ref ptr);
}
}
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working