Memory leak when using PyQt with OpenNMT CTranslate

Giuseppe Corbelli corbelligiuseppe at
Thu Nov 5 11:31:45 GMT 2020

On 11/5/20 2:54 AM, Admin Argos Open Technologies, LLC wrote:
> Hi Giuseppe,
> Thanks for the response. What do you mean by "call the base class event 
> loop (QThread::run())"? My understanding was that my code is 
> reimplementing QThread::run in a subclass of QThread and that 
> QThread::run is called via QThread::start. Also I think that the event 
> loop is run by QApplication::exec_.

Well, if you want your thread to interact with main app using signals & 
slots you need to have an event loop for each thread (and use 
moveToThread where necessary). That's what the QThread::run() does.

Yes, you call start() and run() is called. Remember that thread exits 
when run() returns.

> I was able to decently work around this issue so it's not a major 
> problem for me anymore but I haven't been able to find any explanation 
> for why the posted code leaks memory.
Ah well, regarding the memory leak I did not look into the details so I 
have no suggestion.

Giuseppe Corbelli

More information about the PyQt mailing list