Memory leak with QLocalSocket
I'm using a Win7 Desktop, VisualStudio2010 and QT 4.7.4
I am writing a software which send some audio streams to an other application. I use QLocalSocket for the "inter process communication"
In the first release of my program GUI and the working and sending part was in the same thread. If I sending data the private memory (using process explorer to see properties of the running program) of the program increase proportional to the data which I send and if the stream is empty the memory clears (I don't know why).
Now I split the Gui from the working and sending part (QLocalSocket instantiate in the new Thread). The memory did not free. But the program works except the memory leak.
Can someone tell me how the QLocalSocket normally free the memory. I believe that I forgot some things in the new thread and I'm not very familiar with threads in QT.
Thanks in advance.
This could have many reasons, for example buffering and memory allocation strategy, of Qt, the system library or the operating system - it needs not to be a memory leak. Make sure you are really suffering from a memory leak using valgrind, Purify, Visual Studio or alike. This also has the advantage, that such tools most probably can tell you where you actually leak memory.
I didn't found a memory leak in my code (maybe I'm wrong). If I remove the write functions to the socket object is there no increasing memory use. That's the reason that I believe the leak is in the socket object.
If I delete the QLocalSocket object in the thread, the memory is free. Than I instantiate the QLocalSocket again and all runs.
But I think it's not a good style to delete and instantiate an object again and again.