Reputation: 1047
I have in a JSON folder on a server about 2000 products. Each one has price,available_sizes and many more entries. For this reason I decide to make an on the fly binding, by using the RESTTemplate class of the Spring for Android framework. This is working perfectly fine. However, I detect with with MAT(Memory Analyzer Tool) that maybe this approach is too heavy for a mobile because detects possible memory leak.
Here there are the Pojo attributes:
@JsonProperty
private String brand;
@JsonProperty
private String colours;
@JsonProperty
private String img;
@JsonProperty
private Float GBP;
@JsonProperty
private String name;
@JsonProperty
private String prodnum;
@JsonProperty
private String sizes;
However, I don't want to use the
System.gc();
and the other related methods because I read that the reduce the performance. Can anyone help and propose me something that could be memory efficient?
Upvotes: 2
Views: 131
Reputation: 7044
You should only load as many item you can display in the device.
Displaying all item is too much, because user may not read them all.
You display 10 ( for example) and upon scroll to the bottom, you display another 10.
To implement something like this, you can use Pagination in List View.
Refer to http://p-xr.com/android-tutorial-dynamicaly-load-more-items-to-the-listview-never-ending-list/
Upvotes: 2