如题。

解决方案 »

  1.   

    代码上加System.out.println(Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory());
    看会不会不停增加
      

  2.   

    内存泄露还是内存不足,内存泄露是指访问了不应该访问的区域。这个问题可能要在native层作检查,除非native方法抛出了Java的异常类型供应用层。public native void myMothod() throw Throwable;或者native里面做等等
      

  3.   

    看到一篇国外文章是这样说的,他用的是Linux平台的Android SDK,但是我想在Windows平台上调试。
    There is an experimental, unsupported feature that you may be able to take advantage of.In your DDMS configuration file (e.g. ~/.android/ddms.cfg on Linux), add "native=true". This enables the Native Heap tab.Next, enable native heap allocation tracking on the device, and restart the app framework:% adb shell setprop libc.debug.malloc 1
    % adb shell stop
    % adb shell start(Note this requires root. Note also that this only applies to recent releases; on older releases you also needed to manually replace libc.so with libc_debug.so in /system/lib on the device.)You can tell if you've got the device configured correctly by watching the logcat output while issuing a simple command ("adb shell ls"). If you see:I/libc ( 4847): ls using MALLOC_DEBUG = 1 (leak checker)
    then you know you've enabled it.Now you can use the Native Heap tab features to grab snapshots of heap memory usage.DDMS will automatically extract symbols from the .../symbols/system/lib shared libraries in your Android source tree. Of course, this requires that you have a full Android source tree, and your device is running code built from it. If not, the stack traces can't be decoded to symbol names, which reduces the usefulness of the feature.