Bonjour à tous,
J'ai écrits un programme qui a pour but de dessiner un rectangle sur une image. Mon souci c'est qu'en passant mon programme sous gdb et valgrind
je constate que j'ai des fuites de mémoire qui sont dû à OpenCV.
Je ne comprends pas d'où viennent ces fuites pouvez-vous m'aidez svp ?
voici mon code :
le message d'erreur sous valgrind :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 int main( int argc, char* argv[]) { IplImage* image; image = cvLoadImage(argv[1],CV_LOAD_IMAGE_UNCHANGED); //dessiner le rectangle cvRectangle(image,cvPoint(10,10),cvPoint(20,30),cvScalar(255,255,255,0),1,8,0); cvNamedWindow("image+rectangle",CV_WINDOW_AUTOSIZE); cvShowImage("image+rectangle",image); cvWaitKey(0); //liberation de la mémoire cvReleaseImage(&image); cvDestroyWindow("image+rectangle"); return(0); }
et gdb :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 ==5057== Memcheck, a memory error detector ==5057== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==5057== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==5057== Command: ./main ==5057== terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid ==5057== ==5057== HEAP SUMMARY: ==5057== in use at exit: 25,683 bytes in 105 blocks ==5057== total heap usage: 124 allocs, 19 frees, 125,519 bytes allocated ==5057== ==5057== LEAK SUMMARY: ==5057== definitely lost: 0 bytes in 0 blocks ==5057== indirectly lost: 0 bytes in 0 blocks ==5057== possibly lost: 1,344 bytes in 34 blocks ==5057== still reachable: 24,339 bytes in 71 blocks ==5057== suppressed: 0 bytes in 0 blocks ==5057== Rerun with --leak-check=full to see details of leaked memory ==5057== ==5057== For counts of detected and suppressed errors, rerun with: -v ==5057== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2) Abandon (core dumped)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid Program received signal SIGABRT, Aborted. 0x00007ffff7015445 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 ../nptl/sysdeps/unix/sysv/linux/raise.c: Aucun fichier ou dossier de ce type. (gdb)
Partager