Android Question LARGE JSON STRING to LIST

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Hi,
i need to split or convert to a list, very large jSON string (30-50 MB) received from a webAPI
when i try to use StringFunction to List i get Error Out of memory
i have a workaround that spit the original string in some little string but i want to knof if exist a way do this
ths
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
Difficile dirlo, troppo poche informazioni.
Comunque, prima cosa da fare è controllare quanta memoria libera ci sia sul tuo dispositivo.

Hard to say, too little information.
However, the first thing to do is check how much free memory there is on your device.

50MB a JSON string? :oops:
 
Upvote 0

Gianni Sassanelli

Active Member
Licensed User
Longtime User
hello Luca,
my device have 6Mb RAM
this occour only in some sporadic cases.

Using sqllite on device the handheld which I feed with data received from SQLserver or other

However, in some cases I need to initialize the database with a list of records taken from a historian

Ciao Luca
il Dispositivo ha 6 Mb ram il messaggio che ricevo
Si sono casi sporadici.
Utilizzo sqllite sul palmare che alimento con dati ricevuti da SQLserver o altro
Mi capita però in alcuni casi di dover inizializzare il db con una lista di record presi da uno storico
 
Upvote 0

emexes

Expert
Licensed User
I have a workaround that split the original string in some little strings

This would seem the simplest solution. 🏆

But if you're already starting to bump up against memory limits because of having two copies of the data in memory at the same time (the JSON string and the List) then perhaps:
* write the string to a file
* set the string to empty "" (so that garbage collector can reclaim that memory if it's needed)
* read the file back using a JSON parser (that can read from a stream or file and output directly to a List)
 
Last edited:
Upvote 0
Top