开发者

Android app service memory usage issues

My android app's service uses 2.9 MB and nearly 5 MB when开发者_StackOverflow社区 there is a notification?

Whether it's good or I should cut down on memory usage?

Can someone tell me the ways to cut down on memory usage?


Its always advisable that your code use optimal memory.

Though this might give you idea about memory state in an app. http://developer.android.com/reference/android/app/ActivityManager.html#getMemoryClass

To go on statistic, in general its 24M.

Whether it's good or I should cut down on memory usage?

Of course why not if its possible.

Can someone tell me the ways to cut down on memory usage?

This is discussed here What are some Java memory management best practices?


Memory is a very precious resource in Android, proper management of Heap Space is very important as the heap size for an Android app can be as low as 16MB (HTC G1).

  • Use logcat effectively to monitor if there are any memory leaks.
  • Use WeakReference/SoftReference to allow GC to collect more objects (more efficiently).
  • Use tools like MAT (for eclipse) to pin point leaks.

Read more about these here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜