News for hackers. Stuff that matters.
Re:LeakCanary: Detect all Android memory leaks by eonwe on Monday May 11, 2015 @04:56AM (#9523416)
Android has precise GC so it will free the unused memory even if there are loops within it.

What it won't help with are cases like: public class MainStuff { private byte[] myBuffer;

      public void doStuff() {
          myBuffer = new byte[20 * 1024 * 1024];
          doStuffWithBuffer(myBuffer);
      }
  
      private void doStuffWithBuffer(byte[] buffer) {
          /* omitted */
      }
  
  }
Here, we program keeps myBuffer around as long as MainStuff lives which can be very long if it is, say, a main class of your program.

It's just that the cases where the memory is kept around are not as easy for the programmer to spot as this example for reference-hierarchies are deeper.

There are no comments on this comment yet.