Use of SAX parser in Android - OutOfMemory Issue

Posted by Sephy on Stack Overflow See other posts from Stack Overflow or by Sephy
Published on 2010-03-14T21:21:40Z Indexed on 2010/03/14 21:25 UTC
Read the original article Hit count: 466

Filed under:
|
|
|

Hi everybody,

I have been using a SAX parser for a while now to get data from various XML, but today i'm banging my head on a new problem with a hudge XML (compared to the previous ones . here around 12k lines) with a lot of repetitive items in it. Most of the time, the items are part of a block :

  <content>

  <item lbl="blabla">
    <item lbl="blabla"/>
    <item lbl="blabla"/>
  </item>

  <item lbl="blabla">
    <item lbl="blabla"/>
    <item lbl="blabla"/>
    <item lbl="blabla"/>
    <item lbl="blabla"/>
    <item lbl="blabla"/>
    <item lbl="blabla"/>
  </item>
</content>

The blabla part is of course changing...But, I would like to keep the structure of items (they are titles and subtitles). And for that, I append each blabla with a starting and ending tag blabla, where x is the position in the tree of items (1, 2, 3 or 4). The slightly problematic part is that with that, I'm creating thousands of useless objects and the garbage collector doesn't have time to clean after the parser, and the inevitable OutOfMemory comes in my face... I have no idea of how to deal with it; The best technique would be if I could take the whole content of , but i'm not sure that this is possible with a SAX parser.

Any help is welcome and any solution deeply thanked...

© Stack Overflow or respective owner

Related posts about android

Related posts about sax