Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think I have found the answer to these questions and as I was wondering... it is related to the Garbage Collector and the use of strong references.</p> <p>In <a href="http://weblogs.java.net/blog/2006/05/04/understanding-weak-references" rel="nofollow">Understanding weak references</a> article it is said that:</p> <blockquote> <p>if an object is reachable via a chain of strong references (strongly reachable), it is not eligible for garbage collection. As you don't want the garbage collector destroying objects you're working on, this is normally exactly what you want</p> </blockquote> <p>In another article <a href="http://javarevisited.blogspot.com/2011/04/garbage-collection-in-java.html" rel="nofollow">How Gargabe Collection works</a> it is explained that:</p> <blockquote> <p>if an object holds reference of another object and when you set container object's reference null, child or contained object automatically becomes eligible for garbage collection.</p> </blockquote> <p>So, my <strong>conclusion</strong> is that:</p> <p>In the first case: As I am setting activity to null in <code>detach()</code> there is no memory leak and all objects can be garbage collected unless the adapter, which has a strong reference. So, I understand that the activity and all other objects contained by it are deleted unless the adapter, this is what I actually want.</p> <p>In the second case: As I am returning the container object (A a) in <code>onRetainNonConfigurationInstance()</code> and it has a strong reference to (B b), b instance is accessible too, because it can be reachable via a chain of strong references.</p> <p>Hope this will be helpful. If anyone else wants to give his/her opinion it will be welcome!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload