nextbreakpoint / nextfractal

NextFractal is an application for creating fractals and other algorithmically generated images
GNU General Public License v3.0
17 stars 6 forks source link

java.lang.OutOfMemoryError: Java heap space #29

Closed linux-man closed 3 years ago

linux-man commented 3 years ago

This issue happens on rendering a png 2048x2048 of spiral-001.nf. Same error on v.2.1.2 and current 2.2.0.

Same arguments:

JVM arguments:
--module-path=/home/joao/bin/NextFractal2.2/jars
--add-modules=ALL-MODULE-PATH
-Djava.library.path=/home/joao/bin/NextFractal2.2
-Dbrowser.location=/home/joao/bin/NextFractal2.2/examples
-Djava.util.logging.config.class=com.nextbreakpoint.nextfractal.runtime.logging.LogConfig
-Xmx4g

On 2.1.2:

2021-03-09 22:04:47 WARNING com.nextbreakpoint.nextfractal.contextfree.renderer.Renderer doRender Cannot render fractal
java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.Arrays.copyOf(Unknown Source)
    at java.base/java.util.ArrayList.grow(Unknown Source)
    at java.base/java.util.ArrayList.grow(Unknown Source)
    at java.base/java.util.ArrayList.add(Unknown Source)
    at java.base/java.util.ArrayList.add(Unknown Source)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.grammar.CFDGRenderer.processPrimShapeSiblings(CFDGRenderer.java:601)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.grammar.CFDGRenderer.processPrimShape(CFDGRenderer.java:520)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.grammar.CFDGRenderer.processShape(CFDGRenderer.java:508)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.grammar.ast.ASTReplacement.traverse(ASTReplacement.java:134)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.grammar.ast.ASTRepContainer.traverse(ASTRepContainer.java:156)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.grammar.ast.ASTRule.traverse(ASTRule.java:150)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.grammar.CFDGRenderer.run(CFDGRenderer.java:767)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.renderer.Renderer.doRender(Renderer.java:331)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.renderer.Renderer$RenderRunnable.run(Renderer.java:424)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

On 2.2.0:

2021-03-09 20:42:10 WARNING com.nextbreakpoint.nextfractal.contextfree.renderer.Renderer doRender Cannot render fractal
java.lang.OutOfMemoryError: Java heap space
    at java.base/java.util.Arrays.copyOf(Unknown Source)
    at java.base/java.util.ArrayList.grow(Unknown Source)
    at java.base/java.util.ArrayList.grow(Unknown Source)
    at java.base/java.util.ArrayList.add(Unknown Source)
    at java.base/java.util.ArrayList.add(Unknown Source)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.dsl.grammar.CFDGRenderer.processPrimShapeSiblings(CFDGRenderer.java:602)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.dsl.grammar.CFDGRenderer.processPrimShape(CFDGRenderer.java:521)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.dsl.grammar.CFDGRenderer.processShape(CFDGRenderer.java:509)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.dsl.grammar.ast.ASTReplacement.traverse(ASTReplacement.java:134)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.dsl.grammar.ast.ASTRepContainer.traverse(ASTRepContainer.java:156)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.dsl.grammar.ast.ASTRule.traverse(ASTRule.java:150)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.dsl.grammar.CFDGRenderer.run(CFDGRenderer.java:768)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.renderer.Renderer.doRender(Renderer.java:330)
    at com.nextbreakpoint.nextfractal.contextfree@2.1.2/com.nextbreakpoint.nextfractal.contextfree.renderer.Renderer$RenderRunnable.run(Renderer.java:422)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

Exception in thread "RxCachedWorkerPoolEvictor-1" java.lang.OutOfMemoryError: Java heap space

My machine has 8G RAM and is running Linux Mint 20.1. Is there anything I can do to help?

linux-man commented 3 years ago

:blush: It turns out that I have java-8-openjdk and java-11-openjdk installed, but java-8-openjdk was the default. Changed to 11 and for now, rendering continues without crashes. I'll try a bigger rendering next days.

nextbreakpoint commented 3 years ago

Also, if you have a problem with the memory limits, consider increasing the max memory -Xmx4g to -Xmx7g. If you are using the native executable, you have to pass an environment variable: NEXTFRACTAL_MAX_MEMORY=7

linux-man commented 3 years ago

2048x2048 rendering of spiral-001.nf is still going, but isn't it taking too long? I'm close to 12 hours of rendering time. It would be nice to have some info, like how much rendering was done.

I have a job at 100% and a string of

2021-03-10 10:14:08 INFO com.nextbreakpoint.nextfractal.runtime.javafx.MainSidePane handleExportSessionStateChanged Session e911c003-56e3-44ab-a424-73ed79a64456 state DISPATCHED
nextbreakpoint commented 3 years ago

The file you mentioned is an example of Context Free image. I am sorry but the current implementation of Context Free rendering is not very mature. As you noticed, it doesn't proved any information about the progress (plus there are other bugs I am afraid). I haven't worked on the code for quite a while, so I can't remember what is the actual reason for that limitation right now, but that is something I'll have to fix. FYI you can render that image using the original C++ app Context Free if you wish.

I would suggest to start with a smaller image, just to see if there isn't any other issue. I usually test the app on Mac, so I might not spot issues which only happen on Linux.

nextbreakpoint commented 3 years ago

I can confirm the issue. I managed to recreate it. I'll have a look. thanks for reporting the issue

nextbreakpoint commented 3 years ago

I found that the render loop of Context Free images is not tuned very well, but it can be improved with some minor changes. I guess I'll be able to release a fix soon. Still, the progress indicator needs improvement, but at least the render should complete in an acceptable time.

linux-man commented 3 years ago

Thank you for pointing the "original" context free app. I can render all, up to 16000 px. Nextfractal is great for prototyping at low res, and is quick rendering the spiral at 1024x1024, but gets stuck at 2048x2048. Some room for improvements, but overall this app is the one that made me enjoy playing with fractals in a long time.

nextbreakpoint commented 3 years ago

I am happy to hear that you like my app :) I wish I had more time to work on it nowadays. The rendering performance in Java is not too bad, but it can't compete with the optimised C++ code of Context Free.

linux-man commented 3 years ago

Can't compare apples to oranges. Keep up the good work. Best of luck!

nextbreakpoint commented 3 years ago

cheers!