PDA

View Full Version : QLocalServer / QLocalSocket major memory leaks?



torrentss
28th July 2010, 23:16
Hello all,

I'm transferring large amounts of data from client process (with QLocalSocket) to QLocalServer.

The problem is, I get some major memory leaks (especially under Linux), as if all my messages are stored somewhere. I modified the stock fortune server/client examples to show what I mean.

Qt 4.6.2 under Linux:
Client process' memory usage increases with every message it sends, proportional to the sent data amount.
Server process' memory usage increases with every received message, but maybe about 1/4 of the client's memory usage.

Qt 4.6.3 under Windows (MSVC):
Client's process doesn't increase its memory usage, it just fluctuates within reasonable limits.
Server process' memory usage increases like in Linux.

I did some checks with valgrind on the client (with --leak-check=full and --show-reachable=yes), it shows:

==25589== 429,916,160 bytes in 205 blocks are still reachable in loss record 938 of 938
==25589== at 0x4C242DE: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25589== by 0x5E8C549: QByteArray::realloc(int) (qbytearray.cpp:1424)
==25589== by 0x5E8C92D: QByteArray::resize(int) (qbytearray.cpp:1380)
==25589== by 0x5B8F53E: QRingBuffer::reserve(int) (qringbuffer_p.h:175)
==25589== by 0x5B8A22D: QAbstractSocket::writeData(char const*, long long) (qabstractsocket.cpp:2156)
==25589== by 0x5F13800: QIODevice::write(char const*, long long) (qiodevice.cpp:1324)
==25589== by 0x4049D2: LocalClient::send(QByteArray const&) (qiodevice.h:127)
==25589== by 0x40444A: Client::sendData() (client.cpp:93)
==25589== by 0x404CEC: Client::qt_metacall(QMetaObject::Call, int, void**) (moc_client.cpp:72)
==25589== by 0x5F95E96: QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (qobject.cpp:3293)
==25589== by 0x5698141: QAbstractButton::clicked(bool) (moc_qabstractbutton.cpp:206)
==25589== by 0x53AC98A: QAbstractButtonPrivate::emitClicked() (qabstractbutton.cpp:546)


Looks like there is some continuous allocation within QAbstractSocket or QRingBuffer?

I ran the server through valgrind as well, but there were no leaks of any major size (I guess they are freed automatically).

So, it seems there are 2 problems here - one is in Linux only (client), the other is in both Linux and Windows (server).

Can anyone please reproduce this? Do I have some silly bug in my code (attached)?
Should this be reported to Nokia?

Thanks a lot in advance!