如何处理OutOfMemoryError 1040KB堆栈失败此错误

时间:2019-01-07 08:04:22

标签: android event-handling out-of-memory

我正在使用Retrofit将服务器数据库中存储的某些数据发布到服务器。问题是,当API命中40至50次后,我发布了代码和错误,请检查并提出正确的方法来解决问题并崩溃。错误是:

java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
    at java.lang.Thread.nativeCreate(Native Method)
    at java.lang.Thread.start(Thread.java:733)
    at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:975)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1393)
    at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:276)
    at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
    at $Proxy0.getRideDetail(Unknown Source)
    at qwykr.rydier.interactorImpl.HomeScreenInteractorImpl.checkRideStatus(HomeScreenInteractorImpl.java:149)
    at qwykr.rydier.interactorImpl.HomeScreenInteractorImpl$6.success(HomeScreenInteractorImpl.java:189)
    at qwykr.rydier.interactorImpl.HomeScreenInteractorImpl$6.success(HomeScreenInteractorImpl.java:149)
    at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

,这是翻新代码:对第一行的崩溃影响。我还将使用线程和背景方法处理应用程序和数据。请提出正确的一个想法

 RetroUtils.getHostAdapter(activity,ApiEndpointInterface.URL).create(ApiEndpointInterface.class).getRideDetail(rideID, new Callback<ArringDriverResponse>() {
                @Override
                public void success(ArringDriverResponse arringDriverResponse, Response response) {

                }

                @Override
                public void failure(RetrofitError retrofitError) {
                    System.out.println("RdieM Ain   "+retrofitError.getMessage());
                }
            });

1 个答案:

答案 0 :(得分:0)

1:在清单应用部分中,添加以下内容

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form class="ajax" method="POST" action="">
  <p class="error-message" id="error-message"></p>
  <select name="title" id="title" class="wrap-input2 validate-input">
    <option value="">Title</option>
    <option value="Mr">Mr</option>
    <option value="Ms">Ms</option>
    <option value="Miss">Miss</option>
    <option value="Mrs">Mrs</option>
    <option value="Sir">Sir</option>
    <option value="Dr">Dr</option>
    <option value="Prof">Prof</option>
    <option value="Mstr">Mstr</option>
  </select>
  <div class="wrap-input2 validate-input">
    <input class="input2" name="forename" id="forename">
  </div>
  <div class="wrap-input2 validate-input">
    <input class="input2" name="surename" id="surename" `>
  </div>
  <div class="wrap-input2 validate-input">
    <input class="input2" name="email" id="email" type="email" required>
  </div>
  <input class="spin" type="image" src="images/click.png" alt="Submit">
</form>

2:否1是您必须找出真正原因并加以解决的临时解决方案。您可以使用库来跟踪内存泄漏。 https://github.com/square/leakcanary