什么是内部类的综合反向引用 [英] What is a synthetic back reference to an inner class

查看:89
本文介绍了什么是内部类的综合反向引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找应用程序中的内存泄漏,并且正在使用的探查器告诉我要寻找这些类型的引用,但我不知道我要寻找什么.有人可以解释一下吗?

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?

谢谢

埃利奥特

推荐答案

您可以对OUTER类(而不是内部类实例)进行综合的反向引用.

You can have synthetic back reference to an OUTER class, but not inner class instances.

例如

class Outer {

    class Inner {
    }

    static class Nested {
    }
}

在此示例中,Inner具有对Outer类的引用.嵌套不.如果外部较大,则意味着您可以握住不需要的物体.

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.

简而言之,请尽可能使内部类为static.

In short, make inner classes static if you can.

这篇关于什么是内部类的综合反向引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆