Bonjour,
Lorsque j'exécute le programme très simple suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
#include <iostream>
#include <QUdpSocket>
#include <QHostAddress>
 
using namespace std;
 
int main(int argc, char *argv[])
{
  QUdpSocket  *socket = new QUdpSocket();
  delete(socket);
  return 0;
}
ou bien le programme suivant :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
#include <iostream>
#include <QUdpSocket>
#include <QHostAddress>
 
using namespace std;
 
int main(int argc, char *argv[])
{
  QUdpSocket  socket;
  return 0;
}
et que je regarde les fuites de mémoires avec valgrind, il y a apparement de la mémoire non libérée:


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
chris@chris-laptop:~/Bureau/qt$ valgrind --leak-check=yes ./qt
==2161== Memcheck, a memory error detector
==2161== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==2161== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==2161== Command: ./qt
==2161== 
==2161== 
==2161==  HEAP SUMMARY:
==2161==     in use at exit: 1,184 bytes in 10 blocks
==2161==   total heap usage: 61 allocs, 51 frees, 4,706 bytes allocated
==2161== 
==2161== LEAK SUMMARY:
==2161==    definitely lost: 0 bytes in 0 blocks
==2161==    indirectly lost: 0 bytes in 0 blocks
==2161==      possibly lost: 0 bytes in 0 blocks
==2161==    still reachable: 1,184 bytes in 10 blocks
==2161==         suppressed: 0 bytes in 0 blocks
==2161== Reachable blocks (those to which a pointer was found) are not shown.
==2161== To see them, rerun with: --leak-check=full --show-reachable=yes
==2161== 
==2161== For counts of detected and suppressed errors, rerun with: -v
==2161== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 67 from 8)

Le détail des blocs non libérés est

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
 
chris@chris-laptop:~/Bureau/qt$ valgrind --leak-check=full --show-reachable=yes ./qt
==2164== Memcheck, a memory error detector
==2164== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==2164== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==2164== Command: ./qt
==2164== 
==2164== 
==2164== HEAP SUMMARY:
==2164==     in use at exit: 1,184 bytes in 10 blocks
==2164==   total heap usage: 61 allocs, 51 frees, 4,706 bytes allocated
==2164== 
==2164== 4 bytes in 1 blocks are still reachable in loss record 1 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C1478B: QMutexPool::get(void const*) (qmutexpool.cpp:137)
==2164==    by 0x4D25BB7: signalSlotLock(QObject const*) (qobject.cpp:112)
==2164==    by 0x4D2C81A: QObject::~QObject() (qobject.cpp:892)
==2164==    by 0x4CA71C7: QIODevice::~QIODevice() (qiodevice.cpp:405)
==2164==    by 0x4B68941: QAbstractSocket::~QAbstractSocket() (qabstractsocket.cpp:1260)
==2164==    by 0x4B6D1FC: QUdpSocket::~QUdpSocket() (qudpsocket.cpp:224)
==2164==    by 0x80488B3: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 8 bytes in 1 blocks are still reachable in loss record 2 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C1831D: QThreadData::current() (qthread_unix.cpp:151)
==2164==    by 0x4D2AB26: QObject::QObject(QObjectPrivate&, QObject*) (qobject.cpp:799)
==2164==    by 0x4CA728F: QIODevice::QIODevice(QIODevicePrivate&, QObject*) (qiodevice.cpp:391)
==2164==    by 0x4B6415F: QAbstractSocket::QAbstractSocket(QAbstractSocket::SocketType, QAbstractSocketPrivate&, QObject*) (qabstractsocket.cpp:1222)
==2164==    by 0x4B6D26E: QUdpSocket::QUdpSocket(QObject*) (qudpsocket.cpp:212)
==2164==    by 0x80488A7: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 56 bytes in 1 blocks are still reachable in loss record 3 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C182EB: QThreadData::current() (qthread_unix.cpp:148)
==2164==    by 0x4D2AB26: QObject::QObject(QObjectPrivate&, QObject*) (qobject.cpp:799)
==2164==    by 0x4CA728F: QIODevice::QIODevice(QIODevicePrivate&, QObject*) (qiodevice.cpp:391)
==2164==    by 0x4B6415F: QAbstractSocket::QAbstractSocket(QAbstractSocket::SocketType, QAbstractSocketPrivate&, QObject*) (qabstractsocket.cpp:1222)
==2164==    by 0x4B6D26E: QUdpSocket::QUdpSocket(QObject*) (qudpsocket.cpp:212)
==2164==    by 0x80488A7: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 80 bytes in 1 blocks are still reachable in loss record 4 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C19381: QWaitCondition::QWaitCondition() (qwaitcondition_unix.cpp:116)
==2164==    by 0x4C15DAF: QThreadPrivate::QThreadPrivate(QThreadData*) (qthread.cpp:177)
==2164==    by 0x4C15FA9: QAdoptedThread::QAdoptedThread(QThreadData*) (qthread.cpp:137)
==2164==    by 0x4C1832C: QThreadData::current() (qthread_unix.cpp:151)
==2164==    by 0x4D2AB26: QObject::QObject(QObjectPrivate&, QObject*) (qobject.cpp:799)
==2164==    by 0x4CA728F: QIODevice::QIODevice(QIODevicePrivate&, QObject*) (qiodevice.cpp:391)
==2164==    by 0x4B6415F: QAbstractSocket::QAbstractSocket(QAbstractSocket::SocketType, QAbstractSocketPrivate&, QObject*) (qabstractsocket.cpp:1222)
==2164==    by 0x4B6D26E: QUdpSocket::QUdpSocket(QObject*) (qudpsocket.cpp:212)
==2164==    by 0x80488A7: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 96 bytes in 1 blocks are still reachable in loss record 5 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C131B2: QMutex::QMutex(QMutex::RecursionMode) (qmutex.cpp:123)
==2164==    by 0x4C15CD0: QThreadData::QThreadData(int) (qthread_p.h:110)
==2164==    by 0x4C182FF: QThreadData::current() (qthread_unix.cpp:148)
==2164==    by 0x4D2AB26: QObject::QObject(QObjectPrivate&, QObject*) (qobject.cpp:799)
==2164==    by 0x4CA728F: QIODevice::QIODevice(QIODevicePrivate&, QObject*) (qiodevice.cpp:391)
==2164==    by 0x4B6415F: QAbstractSocket::QAbstractSocket(QAbstractSocket::SocketType, QAbstractSocketPrivate&, QObject*) (qabstractsocket.cpp:1222)
==2164==    by 0x4B6D26E: QUdpSocket::QUdpSocket(QObject*) (qudpsocket.cpp:212)
==2164==    by 0x80488A7: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 96 bytes in 1 blocks are still reachable in loss record 6 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C131B2: QMutex::QMutex(QMutex::RecursionMode) (qmutex.cpp:123)
==2164==    by 0x4C15CF0: QThreadData::QThreadData(int) (qthread.cpp:81)
==2164==    by 0x4C182FF: QThreadData::current() (qthread_unix.cpp:148)
==2164==    by 0x4D2AB26: QObject::QObject(QObjectPrivate&, QObject*) (qobject.cpp:799)
==2164==    by 0x4CA728F: QIODevice::QIODevice(QIODevicePrivate&, QObject*) (qiodevice.cpp:391)
==2164==    by 0x4B6415F: QAbstractSocket::QAbstractSocket(QAbstractSocket::SocketType, QAbstractSocketPrivate&, QObject*) (qabstractsocket.cpp:1222)
==2164==    by 0x4B6D26E: QUdpSocket::QUdpSocket(QObject*) (qudpsocket.cpp:212)
==2164==    by 0x80488A7: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 96 bytes in 1 blocks are still reachable in loss record 7 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C131B2: QMutex::QMutex(QMutex::RecursionMode) (qmutex.cpp:123)
==2164==    by 0x4C15D8A: QThreadPrivate::QThreadPrivate(QThreadData*) (qthread.cpp:177)
==2164==    by 0x4C15FA9: QAdoptedThread::QAdoptedThread(QThreadData*) (qthread.cpp:137)
==2164==    by 0x4C1832C: QThreadData::current() (qthread_unix.cpp:151)
==2164==    by 0x4D2AB26: QObject::QObject(QObjectPrivate&, QObject*) (qobject.cpp:799)
==2164==    by 0x4CA728F: QIODevice::QIODevice(QIODevicePrivate&, QObject*) (qiodevice.cpp:391)
==2164==    by 0x4B6415F: QAbstractSocket::QAbstractSocket(QAbstractSocket::SocketType, QAbstractSocketPrivate&, QObject*) (qabstractsocket.cpp:1222)
==2164==    by 0x4B6D26E: QUdpSocket::QUdpSocket(QObject*) (qudpsocket.cpp:212)
==2164==    by 0x80488A7: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 96 bytes in 1 blocks are still reachable in loss record 8 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C131B2: QMutex::QMutex(QMutex::RecursionMode) (qmutex.cpp:123)
==2164==    by 0x4C147A3: QMutexPool::get(void const*) (qmutexpool.cpp:137)
==2164==    by 0x4D25BB7: signalSlotLock(QObject const*) (qobject.cpp:112)
==2164==    by 0x4D2C81A: QObject::~QObject() (qobject.cpp:892)
==2164==    by 0x4CA71C7: QIODevice::~QIODevice() (qiodevice.cpp:405)
==2164==    by 0x4B68941: QAbstractSocket::~QAbstractSocket() (qabstractsocket.cpp:1260)
==2164==    by 0x4B6D1FC: QUdpSocket::~QUdpSocket() (qudpsocket.cpp:224)
==2164==    by 0x80488B3: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 108 bytes in 1 blocks are still reachable in loss record 9 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4C15F98: QAdoptedThread::QAdoptedThread(QThreadData*) (qthread.cpp:137)
==2164==    by 0x4C1832C: QThreadData::current() (qthread_unix.cpp:151)
==2164==    by 0x4D2AB26: QObject::QObject(QObjectPrivate&, QObject*) (qobject.cpp:799)
==2164==    by 0x4CA728F: QIODevice::QIODevice(QIODevicePrivate&, QObject*) (qiodevice.cpp:391)
==2164==    by 0x4B6415F: QAbstractSocket::QAbstractSocket(QAbstractSocket::SocketType, QAbstractSocketPrivate&, QObject*) (qabstractsocket.cpp:1222)
==2164==    by 0x4B6D26E: QUdpSocket::QUdpSocket(QObject*) (qudpsocket.cpp:212)
==2164==    by 0x80488A7: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== 544 bytes in 1 blocks are still reachable in loss record 10 of 10
==2164==    at 0x4025390: operator new(unsigned int) (vg_replace_malloc.c:214)
==2164==    by 0x4D25BD3: signalSlotLock(QObject const*) (qobject.cpp:107)
==2164==    by 0x4D2C81A: QObject::~QObject() (qobject.cpp:892)
==2164==    by 0x4CA71C7: QIODevice::~QIODevice() (qiodevice.cpp:405)
==2164==    by 0x4B68941: QAbstractSocket::~QAbstractSocket() (qabstractsocket.cpp:1260)
==2164==    by 0x4B6D1FC: QUdpSocket::~QUdpSocket() (qudpsocket.cpp:224)
==2164==    by 0x80488B3: main (in /home/chris/Bureau/qt/qt)
==2164== 
==2164== LEAK SUMMARY:
==2164==    definitely lost: 0 bytes in 0 blocks
==2164==    indirectly lost: 0 bytes in 0 blocks
==2164==      possibly lost: 0 bytes in 0 blocks
==2164==    still reachable: 1,184 bytes in 10 blocks
==2164==         suppressed: 0 bytes in 0 blocks
==2164== 
==2164== For counts of detected and suppressed errors, rerun with: -v
==2164== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 67 from 8)
Comment cela se fait-il ? Constater ca me rebute pas mal à utiliser Qt.... Si rien qu'en créant un objet la mémoire n'est pas correctement libéré, j'ai peur de ce qu'il pourrait se passer sur une grosse application....
Merci pour votre aide.