mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Correctly track memory for image pyramid functions
This commit is contained in:
parent
9646626e3d
commit
e1c0d8ef4e
@ -2180,14 +2180,20 @@ NAN_METHOD(Matrix::WarpAffine) {
|
||||
NAN_METHOD(Matrix::PyrDown) {
|
||||
SETUP_FUNCTION(Matrix)
|
||||
|
||||
int oldSize = self->mat.dataend - self->mat.datastart;
|
||||
cv::pyrDown(self->mat, self->mat);
|
||||
int newSize = self->mat.dataend - self->mat.datastart;
|
||||
Nan::AdjustExternalMemory(newSize - oldSize);
|
||||
return;
|
||||
}
|
||||
|
||||
NAN_METHOD(Matrix::PyrUp) {
|
||||
SETUP_FUNCTION(Matrix)
|
||||
|
||||
int oldSize = self->mat.dataend - self->mat.datastart;
|
||||
cv::pyrUp(self->mat, self->mat);
|
||||
int newSize = self->mat.dataend - self->mat.datastart;
|
||||
Nan::AdjustExternalMemory(newSize - oldSize);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -825,6 +825,43 @@ test("Matrix reshape", t=>{
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("Matrix pyrDown", t=>{
|
||||
gc();
|
||||
var startingMemory = process.memoryUsage().external;
|
||||
|
||||
var image = new cv.Matrix(100, 100, cv.Constants.CV_8UC3, [0,0,0]);
|
||||
t.equal(process.memoryUsage().external - startingMemory, 30000); //100 * 100 * 3
|
||||
|
||||
image.pyrDown();
|
||||
|
||||
t.equal(process.memoryUsage().external - startingMemory, 7500); //50 * 50 * 3
|
||||
|
||||
image.release();
|
||||
|
||||
var endingMemory = process.memoryUsage().external;
|
||||
t.equal(endingMemory - startingMemory, 0);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("Matrix pyrUp", t=>{
|
||||
gc();
|
||||
var startingMemory = process.memoryUsage().external;
|
||||
|
||||
var image = new cv.Matrix(100, 100, cv.Constants.CV_8UC3, [0,0,0]);
|
||||
t.equal(process.memoryUsage().external - startingMemory, 30000); //100 * 100 * 3
|
||||
|
||||
image.pyrUp();
|
||||
|
||||
t.equal(process.memoryUsage().external - startingMemory, 120000); //200 * 200 * 3
|
||||
|
||||
image.release();
|
||||
|
||||
var endingMemory = process.memoryUsage().external;
|
||||
t.equal(endingMemory - startingMemory, 0);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
//********************
|
||||
// Additional Asynchronous Matrix Functions
|
||||
//********************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user