1

I have observed that some services allocate <1 Mb of memory. I have tried to do the simplest background service (it prints on log "ok" when it receives a wifi scan broadcast), and I can see that the service allocates around 20 Mb of memory?

1- Why?

2- How can I reduce the allocated memory for my service?

NOTE: I see differences between the 2 ways I tried to measure memory usage.

  1. Using the Android Studio tool "Android Monitor"and
  2. on the phone, under settings\running processes (not sure if it is the right translation to english)
Sorrentum
  • 122
  • 8
  • Did you build/sign as a release and use proguard? – DeeV Jul 06 '16 at 18:37
  • 1
    Please explain *in detail* how you are calculating this memory usage. [Quoting Dianne Hackborn](https://stackoverflow.com/a/2299813/115145), "memory usage on modern operating systems like Linux is an extremely complicated and difficult to understand area. In fact the chances of you actually correctly interpreting whatever numbers you get is extremely low". – CommonsWare Jul 06 '16 at 18:40
  • You could use these tools to measure your app's memory usage: Allocation Tracker https://github.com/square/leakcanary, LeakCanary https://github.com/square/leakcanary I hope it helps. – Arturo Mejia Jul 07 '16 at 19:20
  • @DeeV Now I have made the release build using Proguard (´minimize ´and ´Shrinkresources´) The only result is that the APK file is way lighter, but apparently the memory usage of the app remains more or less the same. Thanks anyway – Sorrentum Jul 13 '16 at 19:04

0 Answers0