title: Strange WeakReference in android staying alive after GC?
body: <p>here is the code</p>
  
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final  WeakReference&lt;Obj&gt; weakReference = new WeakReference&lt;&gt;(new Obj());
  //        just add some code here, gc "works"
  //        int i = 1;
  //        Log.d(TAG, "onCreate: just do something");
          triggerGc();
          if (weakReference.get() != null) {
              Log.d(TAG, "onCreate: NOT reclaimed " + weakReference.get().toString());
          } else {
              Log.d(TAG, "onCreate: reclaimed");
          }
      }
  </code></pre>
  
  <p>Weakly Referred Object was not reclaimed! But GC indeed happened.</p>
  
  <pre><code>D/EnvTest: triggering Gc...
  I/art: Starting a blocking GC Explicit
  I/art: Explicit concurrent mark sweep GC freed 330(35KB) AllocSpace objects, 0(0B) LOS objects, 39% free, 4MB/7MB, paused 115us total 11.164ms
  D/EnvTest: Gc triggered.
  D/EnvTest: onCreate: NOT reclaimed com.example.yves.envtest.MainActivity$Obj@cd043f8
  </code></pre>
  
  <p>if we add some code, like a logging or an assignment, before triggerGc(), the object would be reclaimed as we expect.</p>
  
  <p>here is the triggerGc() method</p>
  
  <pre><code>    private void triggerGc() {
          Log.d(TAG, "triggering Gc...");
          Runtime.getRuntime().gc();
          Runtime.getRuntime().runFinalization();
          Log.d(TAG, "Gc triggered.");
      }
  </code></pre>
  
  <p>Obj here</p>
  
  <pre><code>   static class Obj{
          @Override
          protected void finalize() throws Throwable {
              super.finalize();
              Log.d(TAG, "finalize: ");
          }
      }
  </code></pre>