IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

OpenCV Discussion :

Fuite de mémoire


Sujet :

OpenCV

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    421
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 421
    Points : 95
    Points
    95
    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 : 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);
    }
    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
    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 : 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)

  2. #2
    Membre confirmé

    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    786
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 786
    Points : 602
    Points
    602
    Par défaut
    Et si tu enlèves le waitkey?

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    421
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 421
    Points : 95
    Points
    95
    Par défaut
    si j'enlève le waitKey rien ne change.

  4. #4
    Membre confirmé

    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    786
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 786
    Points : 602
    Points
    602
    Par défaut
    For counts of detected and suppressed errors, rerun with: -v

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    421
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 421
    Points : 95
    Points
    95
    Par défaut
    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 : 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
     
     
    ==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)

  6. #6
    Membre confirmé

    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    786
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 786
    Points : 602
    Points
    602
    Par défaut
    Tu peux essayer de passer en arguments:

    --leak-check=full

    pour voir les leak, si ce n'est pas déjà fait.
    Bon courage.

Discussions similaires

  1. fuite de mémoire ?
    Par salseropom dans le forum C
    Réponses: 2
    Dernier message: 12/01/2006, 16h19
  2. Réponses: 1
    Dernier message: 02/12/2005, 14h18
  3. fuite de mémoire
    Par mamag dans le forum MFC
    Réponses: 17
    Dernier message: 19/08/2005, 10h42
  4. Fuite de mémoire en utilisant le template list
    Par schtroumpf_farceur dans le forum Langage
    Réponses: 9
    Dernier message: 18/07/2005, 20h44
  5. Réponses: 8
    Dernier message: 17/10/2002, 12h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo