我们正在使用musicg库开发应用程序,当我们在eclipse中运行程序时出现内存不足异常。
下面是类
public class FingerprintDemo{
public static void main (String[] args){
String filename = "Fun - Some Nights (ORIGINAL.wav";
// create a wave object
Wave wave = new Wave("D:\\DropBox\\Dropbox\\Convencion 2012\\AUDIOS WAV/"+filename);
// get the fingerprint
byte[] fingerprint=wave.getFingerprint();
// dump the fingerprint
FingerprintManager fingerprintManager=new FingerprintManager();
fingerprintManager.saveFingerprintAsFile(fingerprint, "out/"+filename+".fingerprint");
// load fingerprint from file
byte[] loadedFp=fingerprintManager.getFingerprintFromFile("out/"+filename+".fingerprint");
/*
// fingerprint bytes checking
for (int i=0; i<fingerprint.length; i++){
System.out.println(fingerprint[i]+" vs "+loadedFp[i]);
}
*/
}
}
当我运行这个程序时,它给出了以下异常。
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at com.musicg.wave.extension.Spectrogram.buildSpectrogram(Spectrogram.java:117)
at com.musicg.wave.extension.Spectrogram.<init>(Spectrogram.java:76)
at com.musicg.wave.Wave.getSpectrogram(Wave.java:237)
at com.musicg.fingerprint.FingerprintManager.extractFingerprint(FingerprintManager.java:83)
at com.musicg.wave.Wave.getFingerprint(Wave.java:329)
at com.musicg.main.demo.FingerprintDemo.main(FingerprintDemo.java:31)
我做了类的 jar 并在 Launch4j 中配置它并执行,它工作正常,没有异常。
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>D:\musicg\musicg.jar</jar>
<outfile>D\musicg\\\musicg\.exe</outfile>
<errTitle>MusicG</errTitle>
<cmdLine></cmdLine>
<chdir></chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<customProcName>true</customProcName>
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon></icon>
<jre>
<path>C:\Program Files\Java\jre7\</path>
<minVersion>1.4.0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<initialHeapSize>512</initialHeapSize>
<maxHeapSize>512</maxHeapSize>
</jre>
</launch4jConfig>
如何摆脱这个异常或如何在Eclipse中配置launch4j并调用程序执行?