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
.
精彩评论