Java collection GC
If I created inside method some kind of collection - list, array or map, after exiting from method if this collection contains references also for externa开发者_如何学运维l objects GC free the memory? Or it will be memory leak? Thanks.
No, there will be no leak. Once your code has no references to a given object, the object becomes eligible for garbage collection.
It does not matter whether the object itself (e.g. a collection) contains references to live objects -- it's references in the opposite direction that matter.
精彩评论