Search code examples
javaandroidmemory-managementfinal

android letting a "final" get picked up for GC


Do variables and objects with the keyword final get picked up by gc? I assume this only happens when a final falls out of scope and there's no references left. Is that accurate?


Solution

  • Variables with the final keyword are treated the same as variables without the final keyword by the garbage collector. Therefore after the variable falls out of scope the garbage collector will clean it up next time it checks. You are correct