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