title: How to find how many strong references for a object in heap/stack at runtime
body: <p>Team,</p>
  
  <p>Is there possible in java, to know how many active/strong  references for a object currently available ?</p>
  
  <p>For example in the below code; Object of class A can be hold by many classes in the project. But i want to print that in the monitor thread.</p>
  
  <pre><code>public class A {
    public static A a = new A();
    public static A getInstance() {
       return a;
    }
  
    private A() {
       new Monitor(this).start();
    }
  
  
    class Monitor extends Thread {
        A refA;
        public Monitor(A ref) {
           this.refA = ref;
        }
        public void run () {
  
        //TODO Print how many references currently available for Object A referenced by refA;
        //Sure It will be minimum one. (which is "a" in this class A)   
        } 
  
     }
  }
  </code></pre>
  
  <p>Please don't give much importance to this example program. My question is how to find how many strong references available to an object in the heap/stack? Only good thing is we have one strong reference in hand for that object.</p>
  
  <p>If it is not possible in java; can i pass this strong reference to C language; and from C language can i able to do that?</p>
  
  <p>I just wonder how the Profilers/tools are able to do this?
  Please help.</p>