android获取graphic内存,java - Android graphics huge heap memory consumption? - LibGDX - Stack Overflow...

I currently have a blank LibGDX application that does nothing. It does not render anything, nor does it update anything. It is just an empty Screen. When I deploy the application to android I am greeted with some horrifying memory consumptions. Using DDMS I create the following heap dump when the application is running on my device:

2d98fcb69d1249f6fd5b7ae7f665dec6.png

The most significant use of memory is the 13.163 MB 1-byte array allocation. Isn't this half the heap?!

I checked the allocations and saw that nothing was pointing being allocated of that size:

494632a651505371efc16fd84ae3b5f9.png

Now using Eclipse MAT I analyse the heap dump:

a625ab2fbc2d6c6aa17997ffcdabbf7b.png

So the high use of memory is still coming from byte[] arrays.

Analyzing the byte[] section further I come up with this:

13ea05a61bbce808f3f178bf20b26ca9.png

I now see the huge byte[] allocations are coming from the android graphics. I'm not even drawing anything! Is there any way I can avoid having the android graphics portion of this app take up half of the heap. This just causes excess garbage collection to happen when things are actually going on, or is this normal and I just have to deal with it?

Note: I am running this on a Samsung Galaxy S4 with libGDX version 1.4 (or whatever the latest version is)

UPDATE: I have no discovered that the 14-13MB byte array allocation is normal for applications but I still have a problem. My heap size is too small. If the android graphics take up half of my heap I have little room for anything useful and the garbage collector goes crazy. On another application I created with an older version of libgdx (An undeniably more poorly coded application) and the heap size is 73 Mb. How can I increase the heap size? I presume 73 Mb is fairly large and as you can see most of it is not used. Here are the older application's heap statistics:

eae7af3f7cee46fba34c5862e8a2ab1c.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值