PDA

View Full Version : QProcess doesn't start when memory consumption is too high



bibhukalyana
8th November 2013, 12:02
Hello all,

I am using QProcess class in my application to start external processes and get the reply. Recently I am observing a peculiar case in which when the memory consumption by my application exceeds a particular limit QProcess fails to start throwing the error
QProcess::FailedToStart
But if the same process is started outside application (from command line) when the application is running with full memory usage, it starts and executes successfully.
So what I concluded is that QProcess does some memory/resource check when the function
QProcess::start(..) is called.
Is there anyway I can make QProcess skip this step?
Or if not, then is there any alternative to QProcess for the above mentioned task? Start an external process from inside my application, keep a track of it's status and keep getting all the data sent by the process?


-Thanks,
bibhu

anda_skoa
8th November 2013, 13:29
It is very unlikely that QProcess does any kind of resource check. It is way more likely that your operating system is denying more resources to you program.

Cheers,
_

bibhukalyana
8th November 2013, 13:51
It is very unlikely that QProcess does any kind of resource check. It is way more likely that your operating system is denying more resources to you program.
_

Ok, so in that case how to deal with this situation keeping in my mind that I can't decrease the memory consumption of my program? Can I tell my OS to allocate more resources to my program?

wysota
8th November 2013, 13:57
Which operating system are we talking about?

bibhukalyana
9th November 2013, 09:58
I am using linux 2.6(embedded, arm) and qt version is 4.6.

versat
12th November 2013, 10:00
Hi,
i have the exactly same problem.
Qt 4.6 is running on an embedded system (Linux 2.6.38, ARM926EJ-S).
The error is: Resource error (fork failure): Cannot allocate memory
Since fork makes (somewhat) a copy of the calling process, and my calling process is a bit "bigger", it fails athough there really should be enough free memory for the small shell script that should be called.
Is there an alternative to QProcess that doesn't use fork (that way?)?
Before i implemented QProcess i made a simple system call, but that is really dirty and i want to avoid that.

Best Regards

wysota
12th November 2013, 13:03
You can implement an external daemon that you can contact using some IPC mechanism that will fork itself into the process you want.

bibhukalyana
13th November 2013, 10:32
You can implement an external daemon that you can contact using some IPC mechanism that will fork itself into the process you want.
Couldn't understand anything :confused:. Since i am a beginner so i don't have much idea regarding this. If you can give me a simple example then it would be really great.