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
You can have synthetic back reference to an OUTER class, but not inner class instances.
e.g.
class Outer {
class Inner {
}
static class Nested {
}
}
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.
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:
class Outer {
class Inner {
}
}
In the above code, every instance of Inner
has an instance of Outer
associated with it. The association is maintained through a hidden synthetic member field of Inner
that contains a reference to Outer
.
If the code were changes like so:
class Outer {
static class Inner {
}
}
there would be no such synthetic reference.