【发布时间】:2012-07-17 11:52:41
【问题描述】:
在我的 j2me 应用程序中,每次用户单击某个项目时,我都必须播放一个小声音文件。但问题是当我多次播放声音文件时,比如在 10-14 次之后它给了我 内存不足异常。虽然我每次播放文件时都会释放播放器,但仍然如此 给出内存不足异常:这是代码sn-p,
public void playSound(String soundFile) {
try{
if (player!=null) {
try {
player.deallocate(); //deallocate the unnecessary memory.
} catch (Exception ex) {
player=null;
System.gc();
}
}
player = Manager.createPlayer(getClass().getResourceAsStream(musicFolder + soundFile), "audio/mpeg");
// player = Manager.createPlayer(is, "audio/mpeg");
player.realize();
// get volume control for player and set volume to max
VolumeControl vc = (VolumeControl) player.getControl("VolumeControl");
if (vc != null) {
vc.setLevel(100);
}
player.prefetch();
player.start();
isException=false;
} catch (Exception e) {
isException=true;
}
}
谁能告诉我出了什么问题?
【问题讨论】:
-
请添加手机制造商和型号。此外,代码中的一个指示,您肯定知道哪一行代码会抛出什么 java.lang.Throwable
标签: java memory java-me mp3 mmapi