线程“main”中的异常java.lang.OutOfMemoryError:Java堆空间

时间:2022-06-25 17:34:01

I have written a code and I run it a lot but suddenly I got an OutOfMemoryError:

我编写了一个代码并运行了很多但突然间我得到了一个OutOfMemoryError:

  Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at javax.media.j3d.BoundingBox.<init>(BoundingBox.java:86)
        at javax.media.j3d.NodeRetained.<init>(NodeRetained.java:198)
        at javax.media.j3d.LeafRetained.<init>(LeafRetained.java:40)
        at javax.media.j3d.LightRetained.<init>(LightRetained.java:44)
        at javax.media.j3d.DirectionalLightRetained.<init>(DirectionalLightRetained.java:50)
        at javax.media.j3d.DirectionalLight.createRetained(DirectionalLight.java:116)
        at javax.media.j3d.SceneGraphObject.<init>(SceneGraphObject.java:119)
        at javax.media.j3d.Node.<init>(Node.java:178)
        at javax.media.j3d.Leaf.<init>(Leaf.java:50)
        at javax.media.j3d.Light.<init>(Light.java:270)
        at javax.media.j3d.DirectionalLight.<init>(DirectionalLight.java:87)

5 个解决方案

#1


55  

Well, it's fairly self-explanatory: you've run out of memory.

嗯,这是相当不言自明的:你的内存耗尽了。

You may want to try starting it with more memory, using the -Xmx flag, e.g.

您可能想尝试使用-Xmx标志启动它,使用更多内存,例如:

java -Xmx2048m [whatever you'd have written before]

This will use up to 2 gigs of memory.

这将使用最多2演出的内存。

See the non-standard options list for more details.

有关更多详细信息,请参阅非标准选项列表。

#2


3  

You're out of memory. Try adding -Xmx256m to your java command line. The 256m is the amount of memory to give to the JVM (256 megabytes). It usually defaults to 64m.

你失去了记忆。尝试将-Xmx256m添加到java命令行。 256m是给JVM的内存量(256兆字节)。它通常默认为64米。

#3


3  

I don't know about javax.media.j3d, so I might be mistaken, but you usually want to investigate whether there is a memory leak. Well, as others note, if it was 64MB and you are doing something with 3d, maybe it's obviously too small...

我不知道javax.media.j3d,所以我可能会弄错,但你通常想调查是否有内存泄漏。好吧,正如其他人所说,如果它是64MB并且你正在用3d做某事,也许它显然太小了......

But if I were you, I'll set up a profiler or visualvm, and let your application run for extended time (days, weeks...). Then look at the heap allocation history, and make sure it's not a memory leak.

但如果我是你,我会设置一个分析器或visualvm,让你的应用程序运行更长的时间(几天,几周......)。然后查看堆分配历史记录,并确保它不是内存泄漏。

If you use a profiler, like JProfiler or the one that comes with NetBeans IDE etc., you can see what object is being accumulating, and then track down what's going on.. Well, almost always something is incorrectly not removed from a collection...

如果您使用分析器,如JProfiler或NetBeans IDE等附带的分析器,您可以看到正在积累的对象,然后追踪正在发生的事情。好吧,几乎总是某些东西被错误地从集合中删除。 ..

#4


3  

线程“main”中的异常java.lang.OutOfMemoryError:Java堆空间 -Xmx1024m -XX:MaxPermSize=512m -Xms512m

-Xmx1024m -XX:MaxPermSize = 512m -Xms512m

Add this parameter as argument in your server params

在服务器参数中添加此参数作为参数

#5


2  

If you're recompiling a disassembled APK with APK tool:

如果您使用APK工具重新编译已反汇编的APK:

Just Set Memory Allocation a little bigger

只需将内存分配设置得更大一些

set switch -Xmx1024mto -Xmx2048m

设置开关-Xmx1024mto -Xmx2048m

java -Xmx2048m -jar signapk.jar -w testkey.x509.pem testkey.pk8 "%APKOUT%" "%SIGNED%"

you're good to go.. :)

你很高兴去... :)

#1


55  

Well, it's fairly self-explanatory: you've run out of memory.

嗯,这是相当不言自明的:你的内存耗尽了。

You may want to try starting it with more memory, using the -Xmx flag, e.g.

您可能想尝试使用-Xmx标志启动它,使用更多内存,例如:

java -Xmx2048m [whatever you'd have written before]

This will use up to 2 gigs of memory.

这将使用最多2演出的内存。

See the non-standard options list for more details.

有关更多详细信息,请参阅非标准选项列表。

#2


3  

You're out of memory. Try adding -Xmx256m to your java command line. The 256m is the amount of memory to give to the JVM (256 megabytes). It usually defaults to 64m.

你失去了记忆。尝试将-Xmx256m添加到java命令行。 256m是给JVM的内存量(256兆字节)。它通常默认为64米。

#3


3  

I don't know about javax.media.j3d, so I might be mistaken, but you usually want to investigate whether there is a memory leak. Well, as others note, if it was 64MB and you are doing something with 3d, maybe it's obviously too small...

我不知道javax.media.j3d,所以我可能会弄错,但你通常想调查是否有内存泄漏。好吧,正如其他人所说,如果它是64MB并且你正在用3d做某事,也许它显然太小了......

But if I were you, I'll set up a profiler or visualvm, and let your application run for extended time (days, weeks...). Then look at the heap allocation history, and make sure it's not a memory leak.

但如果我是你,我会设置一个分析器或visualvm,让你的应用程序运行更长的时间(几天,几周......)。然后查看堆分配历史记录,并确保它不是内存泄漏。

If you use a profiler, like JProfiler or the one that comes with NetBeans IDE etc., you can see what object is being accumulating, and then track down what's going on.. Well, almost always something is incorrectly not removed from a collection...

如果您使用分析器,如JProfiler或NetBeans IDE等附带的分析器,您可以看到正在积累的对象,然后追踪正在发生的事情。好吧,几乎总是某些东西被错误地从集合中删除。 ..

#4


3  

线程“main”中的异常java.lang.OutOfMemoryError:Java堆空间 -Xmx1024m -XX:MaxPermSize=512m -Xms512m

-Xmx1024m -XX:MaxPermSize = 512m -Xms512m

Add this parameter as argument in your server params

在服务器参数中添加此参数作为参数

#5


2  

If you're recompiling a disassembled APK with APK tool:

如果您使用APK工具重新编译已反汇编的APK:

Just Set Memory Allocation a little bigger

只需将内存分配设置得更大一些

set switch -Xmx1024mto -Xmx2048m

设置开关-Xmx1024mto -Xmx2048m

java -Xmx2048m -jar signapk.jar -w testkey.x509.pem testkey.pk8 "%APKOUT%" "%SIGNED%"

you're good to go.. :)

你很高兴去... :)