I am looking for memory leaks in my application and the profiler I am using tells me to look for these types of references but I don't know what I'm looking for. Can some one please explain this?
Thanks,
Elliott
I am looking for memory leaks in my application and the profiler I am using tells me to look for these types of references but I don't know what I'm looking for. Can some one please explain this?
Thanks,
Elliott
I don't think there is such thing as synthetic references to an inner class. I think the profiler is talking about references from inner classes to their enclosing classes. These are created when you have code like this:
In the above code, every instance of
Inner
has an instance ofOuter
associated with it. The association is maintained through a hidden synthetic member field ofInner
that contains a reference toOuter
.If the code were changes like so:
there would be no such synthetic reference.
You can have synthetic back reference to an OUTER class, but not inner class instances.
e.g.
In this example, Inner has a reference to the Outer class. Nested does not. If Outer is large this can mean you have can be holding onto an object you don't need.
In short, make inner classes
static
if you can.