On Friday, 17 February 2023 16:16:02 PST Philip Seeger wrote:
> I'm writing 1M chunks of data to a QProcess in a loop until all input
> data is consumed. How do I wait after calling QProcess::write() until
> all data has been sent to the process before calling write() again?
> 
> As documented, I have tried to call waitForBytesWritten(-1) after
> write() but it only helps in the first iteration; then it does not seem
> to block until all bytes are sent to the process. The result is that my
> program uses almost 4G of RES memory if a 4G input file is being read
> and the loop finishes in a second. Closing QProcess actually sends the
> data to the process (takes minutes) and I don't see any progress.

That's correct. The name of the "wait For BytesWritten" method means it waits 
for the bytesWritten signal to be emitted. That is emitted when any byte gets 
written, not when all bytes finish writing.

If after the signal is emitted, bytesToWrite() is still too high for you, you 
can wait again until it drops to a low enough number.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to