0
CvMat* traindata=cvCreateMat(1000,36,CV_32FC1);

When I try to release this matrix using cvReleaseMat(&trainData)

I find memory in the task manager not decreased...instead this release command doesn't have any effect on memory of this application in task manager.

what my doubt is...does cvReleaseMat frees the memory in the CPU also? Or does it just makes that matrix invisble in the future?

hetepeperfan
  • 4,292
  • 1
  • 29
  • 47
user2527599
  • 69
  • 10

1 Answers1

0

Yes cvReleaseMat does free the memory. The task-manager isn't really the tool to look at the memory of the CvMat* allocation. Although if you would make the matrix much larger, you might notice it. This Matrix occupies 1000 * 36 * 4 = 144000 bytes.

You can see it back in the output of the following code analysed by valgrind:

CvMat* traindata = cvCreateMat(1000, 36, CV_32FC1);
//cvReleaseMat(&traindata);

the relevant valgrind output is:

==4967== HEAP SUMMARY:
==4967==     in use at exit: 144,108 bytes in 2 blocks
==4967==   total heap usage: 10 allocs, 8 frees, 144,772 bytes allocated
==4967== 
==4967== LEAK SUMMARY:
==4967==    definitely lost: 64 bytes in 1 blocks
==4967==    indirectly lost: 144,044 bytes in 1 blocks
==4967==      possibly lost: 0 bytes in 0 blocks
==4967==    still reachable: 0 bytes in 0 blocks
==4967==         suppressed: 0 bytes in 0 blocks

but if you actually release the CvMat

CvMat* traindata = cvCreateMat(1000, 36, CV_32FC1);
cvReleaseMat(&traindata);

you get this output notice the output of valgrind now:

==4957== HEAP SUMMARY:
==4957==     in use at exit: 0 bytes in 0 blocks
==4957==   total heap usage: 10 allocs, 10 frees, 144,772 bytes allocated
==4957== 
==4957== All heap blocks were freed -- no leaks are possible
hetepeperfan
  • 4,292
  • 1
  • 29
  • 47
  • i dont know about this valgrind ..but i'm sure this would help me out..can you provide link to any demo examples of using valgrind with OpenCV in Windows – user2527599 Jun 27 '13 at 11:20
  • I posted the link to their website under your original question as comment, you might accept this answer if you think it's good. – hetepeperfan Jun 27 '13 at 11:22
  • @user2527599 about your valgrind question see this thread: http://stackoverflow.com/questions/413477/is-there-a-good-valgrind-substitute-for-windows – hetepeperfan Jun 27 '13 at 11:25