3

My Codename One application downloads around 16000 records of data (approx 10 fields in each record).

On my Android phone (OS6.0, RAM 2GB) it's able to load 8000 to 9000 records but then shows out of memory error.

From the trace, it looks like it run out of heap memory allocated to the app.

Any suggestion what would be the ideal way to handle that large amount of data, please?

Here is the log file

Community
  • 1
  • 1
akash kubavat
  • 847
  • 6
  • 17

2 Answers2

2

The amount of RAM on the phone doesn't mean much. The OS takes about half and then divides the rest to the various apps running in parallel. You would typically have much less see What is the maximum amount of RAM an app can use?

You need to review your code and check what is eating up memory. 16k records of 1kb each would be 16Mb which probably shouldn't crash an app so the question is where is memory taken, I would suggest reading the performance section of the developer guide to figure out memory usage.

Community
  • 1
  • 1
Shai Almog
  • 51,749
  • 5
  • 35
  • 65
2

This might not apply to your situation, but would it be possible to only download x number of records at a time? Then, when the user takes some action (scrolls, hits next page, etc) it loads the next batch? Codename one has a great endless scroller implementation. See here for an example - https://www.codenameone.com/blog/property-cross-revisited.html

Scott Turner
  • 133
  • 5