Android的增长堆断枝情况 [英] Android grow heap frag case

查看:92
本文介绍了Android的增长堆断枝情况的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个应用程序从互联网流媒体音乐......我的应用程序做了很多的东西,它的结构是这样的:我有一个标签视图,每个视图分配在内存中,因此我每次通过标签浏览我再次找到了previous状态(每片也可以打开的WebView查找有关歌曲的信息,新闻等互联网)......所有的生长内存占用,但使应用程序非常人性化......已经注意避免后继Android的指南内存泄漏,我想看看堆的职业,我发现,我的应用程序分配内存最大3.5MB和分配的堆大小为4.5 - 4.6 MB ......我工作在模拟器上。他们没有这么多,我想,但有时我的应用程序重新启动建国LogCat中一个奇怪的消息,像

I'm working on an app to streaming music from internet... My app does many things and it's structured in this way: I have a tab view and every view is allocated in memory so every time I navigate through tabs I find again the previous status ( every tab can also open a webview to find information about songs, news etc in internet ).. all that grows memory occupation but makes the app very user friendly... After having paid attention to avoid memory leaks following the Android guide, I tried to look at the heap occupation and I found that my app allocates max 3.5MB of memory and the heap size allocated is 4.5 - 4.6 MB... I'm working on the emulator .. They are not so much I think, but sometimes my app is restarted founding in LogCat a strange message like

Grow heap ( frag case ) to 3.373 for 19764-byte allocation

这是什么?模拟器的问题?还是其他什么东西?我使用了太多的内存?

What is it? an emulator issue? or something else? Am I using too much memory?

感谢您事先的任何帮助:)

Thank you in advance for any help :)

推荐答案

最大堆大小取决于设备(你可以得到价值通过调用调用Runtime.getRuntime()。maxMemory()),但它的大概在32MB。为了节省内存,Android不自动分配最大内存为每一个应用程序。相反,它会等待,直到应用程序需要更多的内存,然后根据需要,直到它达到最大值赋予了它更多的堆空间。我相信这就是成长堆的消息,你看到的。

The maximum heap size depends on the device (you can get that value by calling Runtime.getRuntime().maxMemory()), but it's probably around 32MB. In order to save memory, Android doesn't allocate maximum memory to every app automatically. Instead it waits until the app need more memory and then gives it more heap space as needed until it's reached the max. I believe that's the Grow heap message you see.

如果你做了很多的内存分配和释放,你可能会遇到碎片问题。维基百科有一个体面的说明<一href="https://secure.wikimedia.org/wikipedia/en/wiki/Fragmentation_%28computer%29#External_fragmentation">here,但基本上意味着你可能需要的可用内存,只是没有在同一个块。因此,有必要增加堆。

If you do a lot of memory allocation and freeing, you may run into fragmentation problems. Wikipedia has a decent description here, but basically means that you might have the required memory available, just not all in one chunk. Hence the need to grow the heap.

因此​​,要回答你的问题,它可能不是一个模拟器的问题,这是你的程序,这听起来有点沉重的记忆刚刚性质。然而,这并不是一件坏事。我不认为使用3-5MB的多个选项卡webviews实在是太多了。

So to answer your questions, it's probably not an emulator issue, it's just the nature of your program, which sounds a little memory heavy. However this isn't a bad thing. I don't think using 3-5MB for multiple tabs with webviews is too much.

这篇关于Android的增长堆断枝情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆