Results 1 to 4 of 4

Thread: Free memory with QProcess

  1. #1
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Free memory with QProcess

    Hi! I run a process using the start method of QProcess:

    Qt Code:
    1. QProcess* proc = new QProcess();
    2. proc->start(path);
    To copy to clipboard, switch view to plain text mode 

    but, is there a way to free the memory after the process has returned? If I delete proc after starting, obviously I get that no process is run... Is there any other way?
    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Free memory with QProcess

    Hi,

    Just connect QProcess::finished signal to your slot, so when the process finish your slot will be executed.
    Òscar Llarch i Galán

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Free memory with QProcess

    If you want to release the QProcess object after it is no longer required then do it... after it is no longer required, i.e. after it signals finished().

    Qt Code:
    1. connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
    To copy to clipboard, switch view to plain text mode 
    Another way is to pass a parent object to QProcess - it will then be deleted when the parent is deleted.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jan 2010
    Posts
    190
    Thanks
    18
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Free memory with QProcess

    This is great! Thank you very much!

Similar Threads

  1. Free memory
    By TomASS in forum Newbie
    Replies: 10
    Last Post: 15th February 2010, 13:50
  2. free up the memory used by QHash
    By vishal.chauhan in forum Qt Programming
    Replies: 8
    Last Post: 22nd June 2009, 19:13
  3. program doesn't seem to free memory, linux
    By JeanC in forum Qt Programming
    Replies: 5
    Last Post: 1st September 2008, 12:06
  4. what is free store in C++ memory?
    By Masih in forum General Programming
    Replies: 6
    Last Post: 2nd July 2007, 22:25
  5. Replies: 2
    Last Post: 13th February 2006, 15:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.