【问题标题】:Caused by: GsaIOException: Error code: 393238 | Buffer overflow, no available space原因:GsaIOException:错误代码:393238 |缓冲区溢出,没有可用空间
【发布时间】:2018-05-10 12:18:03
【问题描述】:

在这里,我有两个活动,Activity_a 带有 some_button 和一个 Activity_B。当Activity_a上点击some_button时,Activity_b会出现。在 Activity_b 中,我尝试使用 retrofit2 获取 JSON_OBJECT 并在 recyclerview 中显示数据。

第一次一切顺利,点击 Activity_a 中的 some_button 后,Activity_b 出现,并在 recyclerView 中显示数据列表。 但是如果我从 Activity_B 按下返回并再次尝试再次单击 Activity_a 的某个按钮,屏幕仍然黑屏并显示以下错误。

引起:com.google.android.apps.gsa.shared.exception.GsaIOException: 错误代码:393238 |缓冲区溢出,没有可用空间。

这个有线问题浪费了我一整天,如果有人之前遇到过同样的问题或对此有任何想法,请帮助我。

Activity_A.java

@Override
public void onClick(View view) {

    if (view.getId() == R.id.fab) {

        Intent activityIntent = new Intent(this, Activity_B.class);
        startActivity(activityIntent);


    }
}

Activity_B.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_message);
    toolbarAndViewInitialization();


    /** Create handle for the RetrofitInstance interface*/
    GetMessageDataService service = RetrofitInstance.getRetrofitInstance().create(GetMessageDataService.class);

    /** Call the method with parameter in the interface to get the notice data*/
    Call<MessageList> call = service.getMessageData();

    /**Log the URL called*/
    Log.wtf("URL Called", call.request().url() + "");

    materialDialog.show();
    call.enqueue(new Callback<MessageList>() {
        @Override
        public void onResponse(Call<MessageList> call, Response<MessageList> response) {
            ArrayList<Message> noticeList = response.body().getMessageArrayList();
            initDataToRecyclerView(noticeList);
            materialDialog.hide();
        }

        @Override
        public void onFailure(Call<MessageList> call, Throwable t) {
            Toast.makeText(MessageActivity.this, "Something went wrong...Error message: " + t.getMessage(), Toast.LENGTH_SHORT).show();
            materialDialog.hide();
        }
    });

}

RetrofitInstance.java

public class RetrofitInstance {

private static Retrofit retrofit;
private static final String BASE_URL2 = "https://someurl.com/";

/**
 * Create an instance of Retrofit object
 */
public static Retrofit getRetrofitInstance() {
    retrofit = new Retrofit.Builder()
            .baseUrl(ApisUtils.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .build();
    return retrofit;
}

public static Retrofit getRetrofitInstance2() {
    retrofit = new Retrofit.Builder()
            .baseUrl(BASE_URL2)
            .addConverterFactory(GsonConverterFactory.create())
            .build();
    return retrofit;
}
}

【问题讨论】:

    标签: android performance memory-leaks out-of-memory retrofit2


    【解决方案1】:

    问题解决了!!

    在我的例子中,这个问题是由于 for 循环 中的愚蠢错误引起的。即使按下后退按钮,for 循环也会继续将数据放入 array_list 并增加内存缓冲区大小。

    【讨论】:

      猜你喜欢
      • 2017-07-14
      • 2011-05-25
      • 2016-08-08
      • 2012-04-26
      • 2017-05-12
      • 1970-01-01
      • 2010-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多