I got outofmemory exception while converting json file to list using Gson
Caused by
java.lang.OutOfMemoryError
Failed to allocate a 18874376 byte
allocation with 18575992 free
bytes and 17MB until OOM, target
footprint 268435456, growth limit
268435456
@Nullable
public <T> List<T> getConvertedListFromJson(JSONArray jsonArray, Class<T> type) throws OutOfMemoryError{
Gson gson = new Gson();
return gson.fromJson(jsonArray.toString(), new ListOf<>(type));
}
How to over come this issue