gpt4 book ai didi

android - Volley - DiskBasedCache OutOfMemory 异常 - 数组大小太大

转载 作者:行者123 更新时间:2023-11-29 00:26:52 24 4
gpt4 key购买 nike

  public void parseInfo(String genderTxt2, Boolean gender){
final String URL = "url" +
"?adult=" + isAdult.toString() + "&gender=" + genderTxt2;

info_text.setVisibility(View.GONE);
listview_progress.setVisibility(View.VISIBLE);
mRequestQueue.add(new JsonObjectRequest(Request.Method.GET,URL,null,new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {

if (!fPullToRefreshAttacher.isRefreshing()) {
names.clear();
}

VolleyLog.v("Response:%n %s", response.toString(4));

adapter.clear();
parseJSON(response);



} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// VolleyLog.e("Error: ", error.getMessage().toString());
Toast.makeText(acc, "Unable to load names list! Please check connection", Toast.LENGTH_LONG).show();
}
}));

mRequestQueue.start();

}

很简单,在许多设备上获取 OutOfMemory 异常。有什么想法吗?

http://crashes.to/s/834735fdc1b/details

最佳答案

我以前遇到过类似的问题。发生的事情是您在解析之前将整个 JSON 对象放入内存中。你想做什么它使用某种阅读器来流式传输它。

https://sites.google.com/site/gson/streaming

来自文档:

Most applications should use only the object model API. JSON streaming is useful in just a few situations:

When it is impossible or undesirable to load the entire object model into memory. This is most relevant on mobile platforms where memory is limited.

When it is necessary to read or write a document before it is completely available.

关于android - Volley - DiskBasedCache OutOfMemory 异常 - 数组大小太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18674056/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com