3 ms·
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 {
by eonwe 11y ago
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.