Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Does closing a QProcess detach it from QSharedMemory it was attached to?



    1. I create a QSharedMemory instance in the main application.
    2. I then create and start a QProcess and wait for it to finish (or time out) in the main application thread
    3. The created process attaches to the QSharedMemory instance and starts doing some computation

    The process then updates the main application on its progress via readyRead(). A progress dialog is being displayed to the user and if they press Cancel, then the process is closed using subProcess->close().

    My question is: Since the child process is killed, is it automatically detached from the QSharedMemory it attached to? Or since it did not detach properly (via QSharedMemory's destructor for example) would there be a memory leak?

    Thanks.


  • Lifetime Qt Champion

    The documentation is imo very clear about this: http://doc.qt.io/qt-5/qsharedmemory.html#details



  • Yes, you are right it is very clear, I should have looked more carefully. Thanks.


Log in to reply