Creating very large image files with BufferedImage, strange issues depending on compilation and computer

半世苍凉 提交于 2019-12-06 14:52:36

Your app is running out of memory - if I calculated it correctly, that image takes about 280MB.

Java programs have a maximum amount of memory they're allowed to use (heap space), which is fixed when the JVM is started, and how this limit is set varies between JVM implementation and versions. When you're running out of memory or close to the limit, the JVM will spend a lot of time doing garbage collection, which will slow it down considerably.

It may be that the only thing you have to do is to give the app more heap space; this is done with the -Xmx command line parameter.

The issue is with the heap size of the Java Virtual Machine -- there just isn't enough on the systems that threw the OutOfMemoryError.

If the problem is occurring with systems running the Sun JVM, it is possible to change the heap size of the JVM by using Sun's JVM-specific options.

As of Sun's Java 6, the default values for the heap size is determined by the amount of system memory, but is also can be overridden by the -Xms option which changes the minimum heap size, and -Xmx that changes the maximum heap size. By default minimum heap size is 1/64 the amount of physical memory, and maximum is 1/4 the amount of physical memory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!