Question : Air 2.0 Native Process: Why does process.standardOutput.readUTFBytes seem to overflow?

Problem:
I am using FB4/SDK 3.5a/ Air2.0 RC1 with a C++ program that returns a very long string (9million chars).

I addapted the tutorial below and as long as my return string is less than circa 3000 chars I don't have a problem. However, when I return the full string the application fails silently.

Can anybody suggest a solution?

Tutorial
http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process.html


1:
2:
3:
4:
// This line of code reads in the string 
// from the C++ std output stream.

var str:String = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);

Answer : Air 2.0 Native Process: Why does process.standardOutput.readUTFBytes seem to overflow?

I would assume this is a Memory issue. As when returning the full string, propably the native code needs to hold the entire String in memory and this is then copied to the Air-Application that then also needs to save it. As full utf needs 2-bytes for each char, you need at least 18MB for that result at least ... times 2 for the Native-Code and the Air Application you start needing a lot of Ram.

You could try to increase the memory reserved to your Air Application.
You could you try to process your data in chunks (3000 char blocks)?
Another solution would be to have your native code to generate the data into a temporary (perhaps even Memory-Mapped) File and to read it with an input stream in Flex. This way you don't have to have too much memory available.
Random Solutions  
 
programming4us programming4us