[android-developers] Re: Large data downloads from a Web app to Android client getting Out of memory error
On Apr 4, 11:51 am, Kostya Vasilyev <kmans...@gmail.com> wrote:
> Perhaps your base64 encoded data doesn't contain line breaks, or contains
> too few of them?
>
There are none; the data stream is a single 5 MB line.
> Causing the readline() to try and read the entire 5 MB (or a large portion
> of it) in memory?
>
Yes, I could alter delivery of the data so that it comes in in smaller
chunks.
> For email content (since you mentioned K9) it's common to line-wrap base64
> data at some reasonable line size, like 76 characters (you know, many
> people still use DOS, even in this day and age).
>
> The same principle could apply to web data.
>
> Besides, line breaks do not have any significance for base64 encoded data
> (unlike, e.g. quoted-printable, or format-flowed text/plain), so you could
> just ignore the line structure.
>
> I'm sure there is piece of code somewhere in K9 sources that can decode
> base64 data on the fly without excessive buffering.
>
> There is also this:
>
> http://developer.android.com/reference/android/util/Base64InputStream...
>
> ... which is part of Android starting with API 8, but hey, the sources are
> only a few clicks away.
Thanks for your ideas, Kostya. The approach I ultimately took was to
save the incoming data to the SD card, in 76 byte pieces, and then
reference it via its Uri. Does the job, albeit somewhat slow. Now I'm
having to deal with the reverse problem: sending a big file up to the
server and I don't think that that can be done in single request, so
I'll probably have to modify the server to support piecewise uploads.
>
> -- K
>
> 4 апреля 2012 г. 22:27 пользователь FractalBob <ruom...@gmail.com> написал:
>
>
>
>
>
>
>
>
>
> > On Apr 4, 8:48 am, TreKing <treking...@gmail.com> wrote:
> > > On Wed, Apr 4, 2012 at 10:38 AM, FractalBob <ruom...@gmail.com> wrote:
> > > > The data, a kind of mail attachment, is a music file
>
> > > Why are you reading lines from this data then?
>
> > The data is coming in Base 64 encoded from the Web app and then passed
> > directly to the processing application. This scheme works fine for all
> > known types of data
> > > > and is eventually loaded into an MP3 player.
>
> > > What does that mean?
>
> > > I can't simply point the player to the file, unfortunately; too much
>
> > > > legacy code.
>
> > > Not sure what that means.
>
> > My app is based on the K9 Mail mail client and it expects the data
> > delivered to its providers in a certain format.
>
> > ---------------------------------------------------------------------------
> > ----------------------
> > > TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> > > transit tracking app for Android-powered devices
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home