title: Retrofit - I/art: Background sticky concurrent mark sweep GC freed
body: <p>I'm trying to make a simple REST request with Retrofit and i'm getting a lot of GC errors. I really don't know how to fix it. I tried to put more memory on emulator but the problem still happens. when make sync call <code>Response&lt;List&lt;User&gt;&gt; response = usersCall.execute();</code>
  following exception</p>
  
  <pre><code>    java.lang.RuntimeException: An error occurred while executing doInBackground()
       android.os.AsyncTask$3.done(AsyncTask.java:309)
      at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
      at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
      at java.util.concurrent.FutureTask.run(FutureTask.java:242)
      at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
  at java.lang.Thread.run(Thread.java:818)
  Cause by: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 2 path $
  at com.google.gson.stream.JsonReader.nextString(JsonReader.java:831)
  at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:422)
  at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:410)
  at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
  at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
  at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:116)
  at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
  at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
  at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:89)
  </code></pre>
  
  <p>and sync call using pojo model <code>Response&lt;List&lt;User&gt;&gt; response = usersCall.execute();</code> then</p>
  
  <pre><code>04-09 07:37:23.897 13396-13411/? I/art: Clamp target GC heap from 111MB to 96MB
  04-09 07:37:23.897 13396-13411/? I/art: Background partial concurrent mark sweep GC freed 3104(48KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 7.520ms total 194.127ms
  04-09 07:37:23.897 13396-13396/? I/art: WaitForGcToComplete blocked for 182.909ms for cause Alloc
  04-09 07:37:23.929 13396-13411/? I/art: Background sticky concurrent mark sweep GC freed 128(5KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 8.237ms total 31.761ms
  04-09 07:37:23.929 13396-13396/? I/art: WaitForGcToComplete blocked for 18.171ms for cause Alloc
  04-09 07:37:24.130 13396-13411/? I/art: Clamp target GC heap from 111MB to 96MB
  04-09 07:37:24.130 13396-13411/? I/art: Background partial concurrent mark sweep GC freed 5784(90KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 9.388ms total 200.412ms
  04-09 07:37:24.130 13396-13396/? I/art: WaitForGcToComplete blocked for 200.758ms for cause Alloc
  04-09 07:37:24.158 13396-13411/? I/art: Background sticky concurrent mark sweep GC freed 1710(34KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 6.897ms total 27.286ms
  04-09 07:37:24.158 13396-13396/? I/art: WaitForGcToComplete blocked for 18.297ms for cause Alloc
  04-09 07:37:24.346 13396-13396/? I/art: Clamp target GC heap from 111MB to 96MB
  04-09 07:37:24.346 13396-13396/? I/art: Alloc partial concurrent mark sweep GC freed 2092(33KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 5.943ms total 188.191ms
  04-09 07:37:24.370 13396-13396/? I/art: Alloc sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 8.501ms total 23.440ms
  04-09 07:37:24.566 13396-13396/? I/art: Clamp target GC heap from 111MB to 96MB
  04-09 07:37:24.566 13396-13396/? I/art: Alloc concurrent mark sweep GC freed 9(12KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 6.105ms total 195.296ms
  04-09 07:37:24.566 13396-13411/? I/art: WaitForGcToComplete blocked for 395.241ms for cause Background
  04-09 07:37:24.598 13396-13411/? I/art: Background sticky concurrent mark sweep GC freed 0(0B) AllocSpace objects, 0(0B) LOS objects, 0% free, 95MB/96MB, paused 6.138ms total 29.195ms
  04-09 07:37:24.598 13396-13396/? I/art: WaitForGcToComplete blocked for 29.063ms for cause Alloc
  04-09 07:37:24.775 13396-13396/? I/art: Clamp target GC heap from 111MB to 96MB
  04-09 07:37:24.775 13396-13396/? I/art: Alloc partial concurrent mark sweep GC freed 16(56KB) AllocSpace objects, 1(54KB) LOS objects, 0% free, 95MB/96MB, paused 6.803ms total 177.429ms
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>Gson gson =
                  new GsonBuilder()
                          .registerTypeAdapter(Usuario.class, new UsuarioDeserializer())
                          .registerTypeAdapter(Date.class, new CustomDateDeserializer())
                          .create();
  
          Retrofit retrofit = new Retrofit.Builder()
                  .baseUrl(ConstantesUtil.URL_BASE)
                  .addConverterFactory(GsonConverterFactory.create(gson))
                  .build();
  
          UsuariosAPI usuarioApi = retrofit.create(UsuariosAPI.class);
  
          Usuario usuario = new Usuario(login, senha);
  
          Call&lt;List&lt;Usuario&gt;&gt; usuarios = usuarioApi.getUsuarios(usuario);
  
          usuarios.enqueue(new Callback&lt;List&lt;Usuario&gt;&gt;() {
              @Override
              public void onResponse(Call&lt;List&lt;Usuario&gt;&gt; call, Response&lt;List&lt;Usuario&gt;&gt; response) {
                  List&lt;Usuario&gt; usuarios = response.body();
  
                  for (Usuario u: usuarios) {
                      Log.i(TAG, u.getNome());
                  }
              }
  
              @Override
              public void onFailure(Call&lt;List&lt;Usuario&gt;&gt; call, Throwable t) {
  
              }
          });
  </code></pre>