Memory Leak in CvTrainTestSplit

asked 2014-08-02 22:48:35 -0600

Kislay gravatar image

the csv file I am working on is this . Below is my code:

int main() {

CvMLData mlData;
mlData.read_csv("car.data");

Mat temp = mlData.get_values();
cout<<temp<<endl;
int numfeatures = temp.cols-1;
mlData.set_response_idx(numfeatures); 

CvTrainTestSplit spl((float)0.5, true);
mlData.set_train_test_split(&spl);

return 0;

}

This program compiles and run fine. But when I run valgrind on it, I get the following output:

==27065== HEAP SUMMARY:

==27065== in use at exit: 6,944 bytes in 2 blocks

==27065== total heap usage: 9,702 allocs, 9,700 frees, 1,415,503 bytes allocated

==27065==

==27065== 6,936 bytes in 1 blocks are definitely lost in loss record 2 of 2

==27065== at 0x4C2C857: malloc (vg_replace_malloc.c:291)

==27065== by 0x4F06B80: cv::fastMalloc(unsigned long) (in usr/local/lib/libopencv_core.so.2.4.9)

==27065== by 0x52CA8B2: CvMLData::set_train_test_split(CvTrainTestSplit const*) (in /usr/local/lib/libopencv_ml.so.2.4.9)

==27065== by 0x400CD4: main (knn_doubt.cpp:21)

==27065==

==27065== LEAK SUMMARY:

==27065== definitely lost: 6,936 bytes in 1 blocks

==27065== indirectly lost: 0 bytes in 0 blocks

==27065== possibly lost: 0 bytes in 0 blocks

==27065== still reachable: 8 bytes in 1 blocks

==27065== suppressed: 0 bytes in 0 blocks

==27065== Reachable blocks (those to which a pointer was found) are not shown.

==27065== To see them, rerun with: --leak-check=full --show-leak-kinds=all

==27065==

==27065== For counts of detected and suppressed errors, rerun with: -v

==27065== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

The line number 21(the one marked in bold above) is where valgrind says it has detected a memory leak. I have no clue what causes this and how to get it away. Please shed some light over this!

edit retag flag offensive close merge delete