[Soot-list] Re : number of class instances

Quentin Sabah quentin.sabah at inria.fr
Wed Mar 14 03:50:33 EDT 2012


Hi Seriai,

> I would like to use Soot to obtain the  references of the instances
> that were created, so that to know whether
> a given class has one or more instances at some point, is this possible to do?

If you want this information at runtime, you can instrument the bytecode following Eric's solution, by declaring a static counter for each class you're interested in and simply increment that counter in the class's constructor(s). This way you'll get the total count of instances for a given class across the program lifetime.

If by "at some point" you mean tracking unreferenced instances (eligible for GC), then it might involve static analyses or GC intrumentation.

-- 
Quentin Sabah, co-funded Ph.D. student
Grenoble University
INRIA-SARDES                   | STMicroelectronics/AST
Montbonnot, France             | Grenoble, France
mailto:quentin.sabah at inria.fr  | mailto:quentin.sabah at st.com
phone: +33 476 61 52 42        | phone: +33 476 58 44 14


More information about the Soot-list mailing list