Java — call Runtime. in the onLowMemory method. gc()
Should we use runtime GC () or system GC () to clear the memory in the production code in the onlowmemory () method in the application class (manual garbage collection)?
Solution
This is a bad practice to use system GC () doesn't mean you use GC manually. It just prompts the JVM to erase the garbage It's best not to use methods like finalize () in objects, which do not provide any guarantee In the Javadoc of the application, the system will execute GC after returning from this method and do so in the correct way
Application javadoc
Therefore, when you return from this method, use system. In the onlowmemory () method GC () will be another garbage collection job From the Javadoc prompt, it is best to lose the cache link in the sample list < Object > bigCache = null; After the method is completed, garbage collection will be performed to obtain the cache list and free memory