4

我的应用程序有一个带有线程的服务,它在后台运行并监听来自远程服务器的通信。当线程运行时,我在我的 LogCat 中看到了很多 dalvikvm 操作。可以吗?或者可能是某种内存泄漏:

这是我的线程运行():

@Override
public void run() {
    startKeepAliveTimer();  
    try {
            socket = new Socket(host, port);
            if (socket != null)
            {
                Log.i("ServerConnection", "Server connection opened");
                this.app.setConnectedToServer(true);
                serverManager.loginToServer();
            }
            else
                app.setConnectedToServer(false);

            while (app.isConnectedToServer()) 
            {
                app.getFacebookManager().refreshAccessToken();                      
                BufferedReader in = new BufferedReader(new InputStreamReader(
                socket.getInputStream()));
                String input;
                input = in.readLine();
                if (input != null)
                {
                    lastOnline = System.currentTimeMillis();
                    input = input.trim();
                    input = app.decrypt(input);
                    Log.e("Server Reponse", input);                 
                    serverManager.processData(app.convertToJSONObject(input));
                }
            }
        } catch (IOException e) {
            Log.e("ServerConnection", e.toString());
        }           

        Log.i("ServerConnection", "Server connection closed");
}

这是我的堆栈跟踪:

paused 8ms
            11-09 15:42:36.862: D/dalvikvm(3806): GC_CONCURRENT freed 1367K, 33% free 10661K/15815K, paused 1ms+2ms
            11-09 15:42:36.892: D/dalvikvm(3806): GC_CONCURRENT freed 1390K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:36.902: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:36.932: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:36.952: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:36.972: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:36.992: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 12ms
            11-09 15:42:37.022: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 2ms+1ms
            11-09 15:42:37.032: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:37.052: D/dalvikvm(3806): GC_CONCURRENT freed 8K, 33% free 10644K/15815K, paused 1ms+1ms
            11-09 15:42:37.072: D/dalvikvm(3806): GC_FOR_ALLOC freed 1406K, 33% free 10629K/15815K, paused 9ms
            11-09 15:42:37.092: D/dalvikvm(3806): GC_CONCURRENT freed 1245K, 33% free 10652K/15815K, paused 1ms+0ms
            11-09 15:42:37.112: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:37.132: D/dalvikvm(3806): GC_CONCURRENT freed 8K, 33% free 10644K/15815K, paused 1ms+1ms
            11-09 15:42:37.152: D/dalvikvm(3806): GC_FOR_ALLOC freed 1406K, 33% free 10629K/15815K, paused 9ms
            11-09 15:42:37.182: D/dalvikvm(3806): GC_CONCURRENT freed 1245K, 25% free 12018K/15815K, paused 1ms+1ms
            11-09 15:42:37.212: D/dalvikvm(3806): GC_CONCURRENT freed 3208K, 33% free 10664K/15815K, paused 1ms+0ms
            11-09 15:42:37.232: D/dalvikvm(3806): GC_FOR_ALLOC freed 1426K, 33% free 10637K/15815K, paused 11ms
            11-09 15:42:37.252: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+0ms
            11-09 15:42:37.272: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:37.302: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 3ms+0ms
            11-09 15:42:37.312: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:37.332: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+0ms
            11-09 15:42:37.362: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 7ms
            11-09 15:42:37.402: D/dalvikvm(3806): GC_CONCURRENT freed 1360K, 33% free 10667K/15815K, paused 1ms+1ms
            11-09 15:42:37.432: D/dalvikvm(3806): GC_CONCURRENT freed 1299K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:37.452: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 13ms
            11-09 15:42:37.472: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:37.492: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 12ms
            11-09 15:42:37.512: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+0ms
            11-09 15:42:37.532: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:37.552: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:37.572: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:37.622: D/dalvikvm(3806): GC_CONCURRENT freed 1266K, 32% free 10761K/15815K, paused 1ms+1ms
            11-09 15:42:37.642: D/dalvikvm(3806): GC_FOR_ALLOC freed 1562K, 33% free 10629K/15815K, paused 13ms
            11-09 15:42:37.672: D/dalvikvm(3806): GC_CONCURRENT freed 1367K, 33% free 10653K/15815K, paused 1ms+1ms
            11-09 15:42:37.692: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:37.712: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:37.722: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:37.752: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 32% free 10758K/15815K, paused 2ms+1ms
            11-09 15:42:37.762: D/dalvikvm(3806): GC_FOR_ALLOC freed 1559K, 33% free 10629K/15815K, paused 11ms
            11-09 15:42:37.792: D/dalvikvm(3806): GC_CONCURRENT freed 1367K, 33% free 10653K/15815K, paused 2ms+1ms
            11-09 15:42:37.812: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:37.832: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:37.852: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:37.872: D/dalvikvm(3806): GC_CONCURRENT freed 8K, 33% free 10644K/15815K, paused 1ms+1ms
            11-09 15:42:37.882: D/dalvikvm(3806): GC_FOR_ALLOC freed 1406K, 33% free 10629K/15815K, paused 9ms
            11-09 15:42:37.912: D/dalvikvm(3806): GC_CONCURRENT freed 1245K, 33% free 10652K/15815K, paused 1ms+0ms
            11-09 15:42:37.932: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:37.962: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 0ms+1ms
            11-09 15:42:37.972: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:38.002: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 32% free 10758K/15815K, paused 1ms+1ms
            11-09 15:42:38.012: D/dalvikvm(3806): GC_FOR_ALLOC freed 1559K, 33% free 10629K/15815K, paused 12ms
            11-09 15:42:38.042: D/dalvikvm(3806): GC_CONCURRENT freed 1367K, 33% free 10653K/15815K, paused 1ms+1ms
            11-09 15:42:38.062: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:38.092: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:38.112: D/dalvikvm(3806): GC_CONCURRENT freed 1293K, 33% free 10652K/15815K, paused 1ms+0ms
            11-09 15:42:38.132: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 13ms
            11-09 15:42:38.162: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 2ms+1ms
            11-09 15:42:38.182: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 11ms
            11-09 15:42:38.202: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+0ms
            11-09 15:42:38.222: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:38.242: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.262: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 7ms
            11-09 15:42:38.272: D/dalvikvm(3806): GC_CONCURRENT freed 8K, 33% free 10644K/15815K, paused 1ms+1ms
            11-09 15:42:38.292: D/dalvikvm(3806): GC_FOR_ALLOC freed 1406K, 33% free 10629K/15815K, paused 8ms
            11-09 15:42:38.322: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10653K/15815K, paused 1ms+1ms
            11-09 15:42:38.342: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 7ms
            11-09 15:42:38.362: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.382: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:38.402: D/dalvikvm(3806): GC_CONCURRENT freed 8K, 33% free 10644K/15815K, paused 1ms+0ms
            11-09 15:42:38.412: D/dalvikvm(3806): GC_FOR_ALLOC freed 1406K, 33% free 10629K/15815K, paused 9ms
            11-09 15:42:38.442: D/dalvikvm(3806): GC_CONCURRENT freed 1245K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.462: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:38.492: D/dalvikvm(3806): GC_CONCURRENT freed 8K, 25% free 12019K/15815K, paused 1ms+2ms
            11-09 15:42:38.522: D/dalvikvm(3806): GC_CONCURRENT freed 3103K, 32% free 10769K/15815K, paused 1ms+2ms
            11-09 15:42:38.532: D/dalvikvm(3806): GC_FOR_ALLOC freed 1570K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:38.552: D/dalvikvm(3806): GC_CONCURRENT freed 1270K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.572: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 7ms
            11-09 15:42:38.592: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:38.622: D/dalvikvm(3806): GC_CONCURRENT freed 1293K, 32% free 10758K/15815K, paused 1ms+1ms
            11-09 15:42:38.632: D/dalvikvm(3806): GC_FOR_ALLOC freed 1559K, 33% free 10629K/15815K, paused 11ms
            11-09 15:42:38.662: D/dalvikvm(3806): GC_CONCURRENT freed 1246K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.682: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 13ms
            11-09 15:42:38.702: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.722: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 11ms
            11-09 15:42:38.742: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.762: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:38.782: D/dalvikvm(3806): GC_CONCURRENT freed 8K, 33% free 10644K/15815K, paused 1ms+1ms
            11-09 15:42:38.802: D/dalvikvm(3806): GC_FOR_ALLOC freed 1406K, 33% free 10629K/15815K, paused 10ms
            11-09 15:42:38.822: D/dalvikvm(3806): GC_CONCURRENT freed 1245K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:38.842: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:38.872: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 24% free 12027K/15815K, paused 1ms+1ms
            11-09 15:42:38.902: D/dalvikvm(3806): GC_CONCURRENT freed 3208K, 33% free 10672K/15815K, paused 1ms+0ms
            11-09 15:42:38.912: D/dalvikvm(3806): GC_FOR_ALLOC freed 1450K, 33% free 10629K/15815K, paused 9ms
            11-09 15:42:38.942: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10653K/15815K, paused 1ms+1ms
            11-09 15:42:38.962: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 7ms
            11-09 15:42:38.982: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.002: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:39.022: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.042: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:39.072: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:39.092: D/dalvikvm(3806): GC_CONCURRENT freed 1390K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:39.112: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:39.132: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+1ms
            11-09 15:42:39.152: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:39.172: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+0ms
            11-09 15:42:39.192: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 11ms
            11-09 15:42:39.212: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.232: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:39.252: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.272: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:39.302: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 2ms+1ms
            11-09 15:42:39.322: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 11ms
            11-09 15:42:39.342: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 2ms+1ms
            11-09 15:42:39.362: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 11ms
            11-09 15:42:39.382: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.402: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 11ms
            11-09 15:42:39.432: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 32% free 10758K/15815K, paused 1ms+1ms
            11-09 15:42:39.442: D/dalvikvm(3806): GC_FOR_ALLOC freed 1559K, 33% free 10629K/15815K, paused 11ms
            11-09 15:42:39.472: D/dalvikvm(3806): GC_CONCURRENT freed 1246K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.492: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 10ms
            11-09 15:42:39.522: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.532: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 8ms
            11-09 15:42:39.562: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 2ms+1ms
            11-09 15:42:39.572: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:39.602: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.612: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 12ms
            11-09 15:42:39.642: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.652: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 9ms
            11-09 15:42:39.682: D/dalvikvm(3806): GC_CONCURRENT freed 1269K, 32% free 10758K/15815K, paused 1ms+2ms
            11-09 15:42:39.692: D/dalvikvm(3806): GC_FOR_ALLOC freed 1559K, 33% free 10629K/15815K, paused 10ms
            11-09 15:42:39.722: D/dalvikvm(3806): GC_CONCURRENT freed 1246K, 33% free 10652K/15815K, paused 1ms+1ms
            11-09 15:42:39.742: D/dalvikvm(3806): GC_FOR_ALLOC freed 1414K, 33% free 10637K/15815K, paused 12ms
            11-09 15:42:39.762: D/dalvikvm(3806): GC_CONCURRENT freed 1366K, 33% free 10661K/15815K, paused 1ms+1ms

更新: 从循环内部删除所有“新”元素后,我使用了 DDMS 分配跟踪器,发现我在 input=in.readLine(); 中有很多分配;InputStream 对象中带有 wrap() 函数的东西……怎么可能?以及该怎么做

4

3 回答 3

5

这应该不是什么大问题——毕竟,这不是一个错误,而是 GC 完成了它的工作。

但是,在这种情况下,每秒都会释放大量内存(并且由于堆的状态保持不变(已分配 - 空闲),这也意味着每秒都会分配此内存。这将加剧电池消耗并会导致您的应用程序滞后。

像其他人建议的那样,尝试在 之外实例化对象while,而不是在每个循环中创建和删除它们。例如,将循环更改为:

BufferedReader in = new BufferedReader(new InputStreamReader(
            socket.getInputStream()));
while (app.isConnectedToServer()) 
        {
            app.getFacebookManager().refreshAccessToken();                      
            String input;
            input = in.readLine();
            if (input != null)
            {
                lastOnline = System.currentTimeMillis();
                input = input.trim();
                input = app.decrypt(input);
                Log.e("Server Reponse", input);                 
                serverManager.processData(app.convertToJSONObject(input));
            }
        }
于 2012-11-09T14:40:28.207 回答
0

当您拥有已创建但不再使用的对象时,垃圾收集器将激活。

这意味着,您的任何new关键字run()(包括在运行中调用的也具有此关键字的方法)都将在以后被垃圾收集。

有些东西必须一直重新创建(例如,Streams),但有些东西可能会保留在内存中(例如,套接字,如果它的生命周期处理得当)。你可以在里面挖startKeepAliveTimer();serverManager.processData(app.convertToJSONObject(input));和其他方法来检查他们是否不是每次都在创建可以在您的服务生命周期中保留的东西。

但尽管如此……在我看来,GC 做得很好,它总是在收集,内存使用相当稳定,我不会太担心。

于 2012-11-09T14:00:14.077 回答
0

我同意布迪乌斯的观点。GC 留给 android 操作系统。如果您的应用程序内存消耗过多,请尝试修改它。使用 MAT 分析器查找内存泄漏。这个视频是关于内存管理的。http://www.youtube.com/watch?v=_CruQY55HOk。. 因此,如果您查看视频,您应该能够摆脱内存泄漏。

此外,如果您有长时间运行的操作,请确保在线程上运行它们。我建议你使用异步任务。在 UI Thread 上运行长时间运行的操作也会导致内存泄漏。

于 2012-11-09T14:21:52.640 回答