incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clemens Wyss - MySign AG <clemens.w...@mysign.ch>
Subject FW: apache-cordova - FileReader#readAsTextFile throws OOM when reading local file
Date Thu, 06 Sep 2012 20:06:53 GMT
"Chunked reading" does not really help when you need to parse json or xml.
We would require
A) streamed File I/O
B) a stream based json parser

I guess jQuery's Ajax (getJSON) does exactly this on the HTTP response
stream. Does anybody now if I could "abuse" jQuery's ajax to parse json
from the local filesystem (not a file in the apk, but one that is on the
devices's filesystem). I tried with the file:/// URI but didn't get hold
of the file ҆

Thx
Clemens

-----------------------------------------
Yup, that's because the data is effectively doubled as it needs to be
passed from the native side to the Javascript side. When you are
downloading the data from the net it is just coming down to the JavaScript
side of things.


Hmmm...I should open an improvement for file reading to do it in chunks.


Simon Mac Donald
http://hi.im/simonmacdonald
On Thu, Sep 6, 2012 at 11:00 AM, Clemens Wyss <clem...@mysign.ch> wrote:


Simon, thx for your reply.
But why then can I download the "same amount" to my device and then save
it? Anda t the very same time the content (being json) is decoded into RAM
...
Only when trying to load from FS I get the OOM ...


-----Urspr√ľngliche Nachricht-----
Von: Simon MacDonald [mailto:simo...@gmail.com]
Gesendet: Donnerstag, 6. September 2012 16:56
An: call...@incubator.apache.org
Betreff: Re: apache-cordova - FileReader#readAsTextFile throws OOM when
reading local file


It's just too much memory for the HTC Desire to handle. Each application
has a piece of the system memory on the HTC Desire the RAM is 384 MB while
on the Samsung Galaxy S2 has 1 GB or RAM. I'm making the assumption that
the available memory for each application is much smaller on the HTC
deviceas it has one third the memory of the Samsung and that's probably
why you
are getting the OOM exception.


Simon Mac Donald
http://hi.im/simonmacdonald
On Thu, Sep 6, 2012 at 8:21 AM, Clemens Wyss - MySign AG <
clem...@mysign.ch> wrote:


Hi all (me being new to this mailinglist),


Context:
cordova 2.0-app on my HTC Desire (Android 2.3.7) jQuery 1.7.1
jQuery.mobile 1.1.1


I try to read a json file (2.5MB) from my HTC Desire.
fileReader.readAsTextFile(...) throws an out of memory exception.
Is 2.5M "too much"?


Thx
Clemens


Note 1:
I am able to download the very file (through $.ajax) and save it
locally using FileWriter. Could it be that in "this case" the file is
being streamed and not completely read into RAM?


Note 2:
Having no problem on a Samsung Galaxy2 with Andorid 4.03  


Mime
View raw message