开发者

Is this a memory leak? - the Context is the Android Context

I ran into out of memory exception on my app. I have code that, in general, does something like below:

while(true)
{
       A.foo(this);
}


public class A
{
    publ开发者_如何学编程ic static void foo(Context c)
    {
       return;
    }
}

Will it leak?


No reference to the Context is held after A.foo(Context) is executed (according to the code you have provided), so you probably do not need to worry about A.foo.

However, having a thread that is running a while(true) loop that never exits can lead to zombie threads that leak out memory - which is more apparent when it holds a reference to a Context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜