Ask Your Question

Revision history [back]

cvReshapeMatND after cvCreateMatND,memory can not be released.

I use OpenCV 2.4.8 with VS2010. When I try to release some memory using the following code, the memory is not released. I think something went wrong with the cvCreateMatND() function. If you comment this function out, the memory can be released.(Please open the windows task manager and watch the memory of the excution.) Please shed me some light about this problem, thank you very much!

#include "stdafx.h"
#include <opencv.hpp>
#include <Windows.h>

using namespace std;
using namespace cv;

int _tmain(int argc, _TCHAR* argv[])
{
    Mat Ca = Mat::zeros(7000, 10000, CV_32FC1);
    for(int i = 0; i < 1000; i++)
    {
        int new_size[2] = {7000, 10000};    

        CvMatND TpCa = Ca;
        CvMatND *Caimg1 = cvCreateMatND(2, new_size, CV_32F);

        cvReshapeMatND(&TpCa, sizeof(CvMatND), Caimg1, 0, 2, new_size);

        cout<<"Before"<<endl;
        Sleep(2000);    
        cvReleaseMatND(&Caimg1);
        cout<<"After"<<endl;
        Sleep(2000);
    }
    return 0;
}
click to hide/show revision 2
retagged

updated 2014-02-17 03:52:46 -0600

berak gravatar image

cvReshapeMatND after cvCreateMatND,memory can not be released.

I use OpenCV 2.4.8 with VS2010. When I try to release some memory using the following code, the memory is not released. I think something went wrong with the cvCreateMatND() function. If you comment this function out, the memory can be released.(Please open the windows task manager and watch the memory of the excution.) Please shed me some light about this problem, thank you very much!

#include "stdafx.h"
#include <opencv.hpp>
#include <Windows.h>

using namespace std;
using namespace cv;

int _tmain(int argc, _TCHAR* argv[])
{
    Mat Ca = Mat::zeros(7000, 10000, CV_32FC1);
    for(int i = 0; i < 1000; i++)
    {
        int new_size[2] = {7000, 10000};    

        CvMatND TpCa = Ca;
        CvMatND *Caimg1 = cvCreateMatND(2, new_size, CV_32F);

        cvReshapeMatND(&TpCa, sizeof(CvMatND), Caimg1, 0, 2, new_size);

        cout<<"Before"<<endl;
        Sleep(2000);    
        cvReleaseMatND(&Caimg1);
        cout<<"After"<<endl;
        Sleep(2000);
    }
    return 0;
}
click to hide/show revision 3
retagged

updated 2014-02-17 03:53:06 -0600

berak gravatar image

cvReshapeMatND after cvCreateMatND,memory can not be released.

I use OpenCV 2.4.8 with VS2010. When I try to release some memory using the following code, the memory is not released. I think something went wrong with the cvCreateMatND() function. If you comment this function out, the memory can be released.(Please open the windows task manager and watch the memory of the excution.) Please shed me some light about this problem, thank you very much!

#include "stdafx.h"
#include <opencv.hpp>
#include <Windows.h>

using namespace std;
using namespace cv;

int _tmain(int argc, _TCHAR* argv[])
{
    Mat Ca = Mat::zeros(7000, 10000, CV_32FC1);
    for(int i = 0; i < 1000; i++)
    {
        int new_size[2] = {7000, 10000};    

        CvMatND TpCa = Ca;
        CvMatND *Caimg1 = cvCreateMatND(2, new_size, CV_32F);

        cvReshapeMatND(&TpCa, sizeof(CvMatND), Caimg1, 0, 2, new_size);

        cout<<"Before"<<endl;
        Sleep(2000);    
        cvReleaseMatND(&Caimg1);
        cout<<"After"<<endl;
        Sleep(2000);
    }
    return 0;
}

cvReshapeMatND after cvCreateMatND,memory can not be released.

I use OpenCV 2.4.8 with VS2010. When I try to release some memory using the following code, the memory is not released. I think something went wrong with the cvCreateMatND() cvReshapeMatND() function. If you comment this function out, the memory can be released.(Please open the windows task manager and watch the memory of the excution.) Please shed me some light about this problem, thank you very much!

#include "stdafx.h"
#include <opencv.hpp>
#include <Windows.h>

using namespace std;
using namespace cv;

int _tmain(int argc, _TCHAR* argv[])
{
    Mat Ca = Mat::zeros(7000, 10000, CV_32FC1);
    for(int i = 0; i < 1000; i++)
    {
        int new_size[2] = {7000, 10000};    

        CvMatND TpCa = Ca;
        CvMatND *Caimg1 = cvCreateMatND(2, new_size, CV_32F);

        cvReshapeMatND(&TpCa, sizeof(CvMatND), Caimg1, 0, 2, new_size);

        cout<<"Before"<<endl;
        Sleep(2000);    
        cvReleaseMatND(&Caimg1);
        cout<<"After"<<endl;
        Sleep(2000);
    }
    return 0;
}