From 1eeae7879cfc2a063b625e35e2ac40469a8f1738 Mon Sep 17 00:00:00 2001 From: Max Ehrlich Date: Thu, 23 Jul 2015 10:34:56 -0400 Subject: [PATCH 1/2] Added release function to attempt to explicitly free mat memory --- src/Matrix.cc | 10 ++++++++++ src/Matrix.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/Matrix.cc b/src/Matrix.cc index 9ce18f3..3308ba4 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -101,6 +101,7 @@ Matrix::Init(Handle target) { NODE_SET_PROTOTYPE_METHOD(ctor, "setWithMask", SetWithMask); NODE_SET_PROTOTYPE_METHOD(ctor, "meanWithMask", MeanWithMask); NODE_SET_PROTOTYPE_METHOD(ctor, "shift", Shift); + NODE_SET_PROTOTYPE_METHOD(ctor, "release", Dispose); target->Set(NanNew("Matrix"), ctor->GetFunction()); }; @@ -2253,3 +2254,12 @@ NAN_METHOD(Matrix::Shift){ NanReturnUndefined(); } + +NAN_METHOD(Matrix::Release) +{ + SETUP_FUNCTION(Matrix) + + mat.release(); + + NanReturnUndefined(); +} diff --git a/src/Matrix.h b/src/Matrix.h index fe24ebc..835baec 100755 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -115,6 +115,8 @@ class Matrix: public node::ObjectWrap { JSFUNC(SetWithMask) JSFUNC(MeanWithMask) JSFUNC(Shift) + + JSFUNC(Release) /* static Handle Val(const Arguments& args); static Handle RowRange(const Arguments& args); From 3655349e83d6408c84f3ef7c865b40fb85d41d2e Mon Sep 17 00:00:00 2001 From: Max Ehrlich Date: Thu, 23 Jul 2015 11:16:27 -0400 Subject: [PATCH 2/2] Fixed function name --- src/Matrix.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Matrix.cc b/src/Matrix.cc index 3308ba4..a00b01e 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -101,7 +101,7 @@ Matrix::Init(Handle target) { NODE_SET_PROTOTYPE_METHOD(ctor, "setWithMask", SetWithMask); NODE_SET_PROTOTYPE_METHOD(ctor, "meanWithMask", MeanWithMask); NODE_SET_PROTOTYPE_METHOD(ctor, "shift", Shift); - NODE_SET_PROTOTYPE_METHOD(ctor, "release", Dispose); + NODE_SET_PROTOTYPE_METHOD(ctor, "release", Release); target->Set(NanNew("Matrix"), ctor->GetFunction()); }; @@ -2257,9 +2257,11 @@ NAN_METHOD(Matrix::Shift){ NAN_METHOD(Matrix::Release) { - SETUP_FUNCTION(Matrix) + NanScope(); - mat.release(); + Matrix *self = ObjectWrap::Unwrap(args.This()); + + self->mat.release(); NanReturnUndefined(); }