Memory leak when using PyQt with OpenNMT CTranslate

Admin Argos Open Technologies, LLC admin at argosopentech.com
Thu Nov 5 01:54:12 GMT 2020


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_.

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.

Forum post
<https://forum.qt.io/topic/120341/how-to-debug-a-hard-to-find-memory-leak-in-pyqt/16>

Thanks,

P.J.

On Tue, Nov 3, 2020 at 4:17 AM Giuseppe Corbelli <corbelligiuseppe at mesdan.it>
wrote:

> On 10/31/20 3:04 PM, Admin Argos Open Technologies, LLC wrote:
> > Hi,
> >
> > Thanks for the suggestion. It does seem like making the GUIWindow the
> > parent of the WorkerThreads is correct and that's what they do in Qt's
> > QThread documentation. I also made a change to connect the QThread's
> > finished signal to its deleteLater slot which is what is done in the
> > documentation's example for subclassing QThread. However, neither of
> > these changes fixed the problem and this example is still leaking memory:
>
> Well, I did not try the example but if you subclass QThread you also
> need to call the base class event loop (QThread::run()) or you won't get
> any signal delivery and the thread will exit as soon as the translator
> is created.
>
> --
> Giuseppe Corbelli
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20201104/f0031203/attachment.htm>


More information about the PyQt mailing list