繁体   English   中英

这是内存泄漏吗? - 上下文是Android上下文

[英]Is this a memory leak? - the Context is the Android Context

我的应用程序遇到内存不足异常。 我有一些代码,通常会执行以下操作:

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


public class A
{
    public static void foo(Context c)
    {
       return;
    }
}

它会泄漏吗?

在执行A.foo(Context)后(根据您提供的代码),不会引用Context ,因此您可能不需要担心A.foo

但是 ,让一个运行一个永不退出的while(true)循环的线程可能导致泄漏内存的僵尸线程 - 当它持有对Context的引用时更为明显。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM