1

I have a problem that Task manager on device claims that my app uses incredible amounts of memory. Numbers like 400MB or even 600MB are common. Dont understand why it shows numbers like that as there is nothing in the app that could make it go into such numbers.

So I read Google docs about memory management, I read tons of other tutorials. My app should be fine, but I went to investigate further by monitoring memory with DDMS. After monitoring the heap there it shows numbers mostly around 40MB allocated with 70MB heap size, so much less that what devices Task manager claims.

I also made heap dumps which I analyzed with MAT and again numbers around 40MB are shown there too.

So why do devices claim that much more memory is used than what Eclipse memory tools show to me? Am I to believe what Task manager shows? Did anyone have problems like this and more importantly what is the cause of this?

Tomáš Chylý
  • 342
  • 1
  • 8
  • 21
  • Do you follow the activity lifecycle properly? Have you checked your layouts for overlapping? Do you handle orientation change and do you use huge Data structures too often? Do you leak any context? Also you might want to check [this](http://developer.android.com/training/articles/memory.html) – Skynet Jun 03 '14 at 06:22
  • Yes, that is the first thing I read. The app is locked to portrait, so no orientation changes. Context is referenced to other objects, that is true and that was the first thing I investigated. I even manually destroyed everything in onDestroy of activity to make sure that nothing is leaked. Why does Eclipse show different numbers than device? Isnt heap essentially the same as memory? It looks to me as the memory tools are totally useless as I have right now commented ut everything in the first activity and device shows 7MB while MAT shows 17MB. – Tomáš Chylý Jun 03 '14 at 07:06
  • Did you try [this](https://developer.android.com/tools/debugging/debugging-memory.html)? – Skynet Jun 03 '14 at 10:25
  • As I already wrote I tried that too, did you read my post? Those memory tools claim that I use only 40-70MB which corresponds to how much the app should use. – Tomáš Chylý Jun 03 '14 at 10:49
  • This cannot fail, there is something missing somewhere. Did you check your memory foot print on different devices. I am very sure that something is missing -- I read your post and I as well know how hard it gets, just kip your calm -- once you resolve this issue, you will feel on top of the world! – Skynet Jun 03 '14 at 10:50
  • Yeah, thats the problem too, Im really irritated because of this problem. Tried to look at it for several days. Another device that I have tested it on went between 200-250MB usually. I would like to test it on another, but dont have right now at my disposal. One of the problems that are there that I know of is Androids problem with drawables. In xml layout I add src to one background image which has 1MB, but in device it takes 18MB. But when I look at Heap dump in MAT, then again there is nothing like that there. – Tomáš Chylý Jun 03 '14 at 11:02

2 Answers2

0

After 3 months I have accidentally found out what the problem was. Some of the fonts that I have used were ArcherSSm in otf format. After replacing them with ttf format all of the memory issues disappeared.

EDIT

Wrong the problem wasnt in the otf format. But in the fonts themselves, ArcherSSm. Other fonts like Helvetica LT in ttf or FuturaStd in otf format are fine.

Tomáš Chylý
  • 342
  • 1
  • 8
  • 21
0

For me, using a global font cache fixed the problem. See here. Seems like old devices leak font assets.

Community
  • 1
  • 1