textSize causing OutOfMemoryError

I have a program that requires textSize to increase over time. When running it gradually, i.e. textSize(4),5,6,7,etc., the number can reach a very high value without anything bad happening. However, if I try to start off with a high value (the same number as gradually approached), it throws an OutOfMemory exception:

java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space at processing.opengl.PSurfaceJOGL$2.run(PSurfaceJOGL.java:484) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.OutOfMemoryError: Java heap space at java.awt.image.DataBufferInt.(DataBufferInt.java:75) at java.awt.image.Raster.createPackedRaster(Raster.java:467) at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032) at java.awt.image.BufferedImage.(BufferedImage.java:324) at processing.core.PFont.(PFont.java:232) at processing.core.PFont.(PFont.java:337) at processing.core.PGraphics.createFont(PGraphics.java:4078) at processing.core.PApplet.createFont(PApplet.java:6254) at processing.core.PApplet.createDefaultFont(PApplet.java:6188) at processing.core.PGraphics.defaultFontOrDeath(PGraphics.java:8219) at processing.core.PGraphics.textSize(PGraphics.java:4391) at processing.core.PApplet.textSize(PApplet.java:12688) at recaman.draw(recaman.java:150) at processing.core.PApplet.handleDraw(PApplet.java:2418) at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:907) at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674) at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147) at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759) at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81) at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452) at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505)

Any help would be appreciated.

Can you please post a MCVE that demonstrates the problem?

As @Kevin mentioned, posting an MCVE, or some code so we can see, would help us see your issue better. But, maybe I can help you out by explaining what the OutOfMemory error is? You mention that it has to do with textSize(), and you also mentioned that you are trying to do something with increasing that over time. How are you doing it?

Do you have textSize(variable) and you have something like: variable++ ? If that keeps on increasing, then you will eventually run out of memory. A way to fix that, would be limiting the amount that your variable can increase with an if statement or some other type of conditional.

That’s a start, and if you still aren’t able to get it working, we would have no problem helping out more, but just post the problematic code so we can help you further.

Hope this helps,