Précédent   Forum du club des développeurs et IT Pro > C et C++ > Bibliothèques > OpenCV
OpenCV Vos questions sur l'API de traitement d'images OpenCV.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 22/10/2012, 12h31   #1
takout
Membre du Club
 
Inscription : janvier 2011
Messages : 373
Détails du profil
Informations forums :
Inscription : janvier 2011
Messages : 373
Points : 54
Points : 54
Par défaut Fuite de mémoire

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 :
Code :
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);
}
le message d'erreur sous valgrind :

Code :
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)
et gdb :
Code :
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)
takout est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/10/2012, 15h00   #2
saturn1
Membre confirmé
 
Inscription : janvier 2008
Messages : 576
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 576
Points : 258
Points : 258
Et si tu enlèves le waitkey?
saturn1 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/10/2012, 17h58   #3
takout
Membre du Club
 
Inscription : janvier 2011
Messages : 373
Détails du profil
Informations forums :
Inscription : janvier 2011
Messages : 373
Points : 54
Points : 54
si j'enlève le waitKey rien ne change.
takout est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/10/2012, 18h41   #4
saturn1
Membre confirmé
 
Inscription : janvier 2008
Messages : 576
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 576
Points : 258
Points : 258
For counts of detected and suppressed errors, rerun with: -v
saturn1 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/10/2012, 19h51   #5
takout
Membre du Club
 
Inscription : janvier 2011
Messages : 373
Détails du profil
Informations forums :
Inscription : janvier 2011
Messages : 373
Points : 54
Points : 54
J'ai pas compris ce que tu veux dire.

Pour gdb c'est bon j'ai trouvé pourquoi ça ne fonctionnait pas.
Par contre valgrind m'informe toujours de fuite de mémoire dû à OpenCV.

valgrind :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
 
==7082== Memcheck, a memory error detector
==7082== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==7082== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==7082== Command: ./main lauryn.jpg
==7082== 
==7082== 
==7082== HEAP SUMMARY:
==7082==     in use at exit: 616,210 bytes in 4,850 blocks
==7082==   total heap usage: 16,576 allocs, 11,726 frees, 5,683,487 bytes allocated
==7082== 
==7082== LEAK SUMMARY:
==7082==    definitely lost: 60 bytes in 1 blocks
==7082==    indirectly lost: 240 bytes in 10 blocks
==7082==      possibly lost: 168,011 bytes in 1,082 blocks
==7082==    still reachable: 447,899 bytes in 3,757 blocks
==7082==         suppressed: 0 bytes in 0 blocks
==7082== Rerun with --leak-check=full to see details of leaked memory
==7082== 
==7082== For counts of detected and suppressed errors, rerun with: -v
==7082== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
takout est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/10/2012, 11h32   #6
saturn1
Membre confirmé
 
Inscription : janvier 2008
Messages : 576
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 576
Points : 258
Points : 258
Tu peux essayer de passer en arguments:

--leak-check=full

pour voir les leak, si ce n'est pas déjà fait.
Bon courage.
saturn1 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 10h27.


 
 
 
 
Partenaires

Hébergement Web