本文介绍了有声短片堆大小溢出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Android应用程序,涉及到多个短的声音片段。目前,我使用的Soundpool 来加载我的声音剪辑一旦第二个活动是由菜单活动开始。我似乎遇到的问题是,一旦这一次要活动开始时,声音剪辑的加载导致多个堆大小溢出,然后经过一些活动的实际负载(模拟器从来没有给出错误或强制退出)。会使用的MediaPlayer 帮助我在这里,并保持这些堆大小溢出的出现?

I'm creating an Android app that involves multiple short sound clips. At the moment, I'm using SoundPool to load my sound clips once a 2nd activity is begun by the menu activity. The problem I seem to be having is that once this secondary activity begins, the loading of the sound clips causes multiple heap size overflows and then after a bit the activity actually loads (the emulator never gives an error or a force quit). Would using the MediaPlayer help me here and keep these heap size overflows from occuring?

此外,此刻,菜单活动开始的第2个活动等待结果(使用 startActivityForResult()函数)。这是否意味着菜单活动正在举行的内存,以及加载第二个活动到内存?如果是这样,我能帮助我的内存问题通过调用完成()上一次注:第二个开始(然后重新启动菜单活动时,用户希望返回菜单活动菜单或将本带来了一个全新的问题?)?

Also, at the moment, the menu activity starts the 2nd activity waiting for a result (using the startActivityForResult() function). Does this mean that the menu activity is being held in memory as well as loading the 2nd activity into memory? If so, could I help my memory issues by calling finish() on the menu activity once the 2nd one is started (then restarting the menu activity when the user wishes to go back to the menu or would this bring up a whole new set of issues?)?

推荐答案

是的,的Soundpool将保留所有的声音在内存中。媒体播放器的单个实例很可能是你所需要的see这里。你应该这样做,你的内存问题应该消失,而不必去任何极端措施。

Yes, soundpool will keep all the sounds in memory. A single instance of media player would probably be all you need see here. You should do this and your memory issues should go away without having to go to any extreme measures.

这篇关于有声短片堆大小溢出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 00:51
查看更多