Note that there are some explanatory texts on larger screens.

plurals
  1. POKinect + Processing + JFrame java.lang.OutOfMemoryError
    text
    copied!<p>I have a problem regarding an actual project using Java, Kinect (OpenNI) and Processing.<br> If I use just Processing and Java everything works fine nothing is stumbling and I get no exceptions.<br> But if I jail the processing Applet in a JFrame (to solve some problems with the Applet Style of Processing) I got the following problem: </p> <ul> <li>Every 3 seconds the kinect images hangs shortly (looks like Java is clearing anything out of the memory using the garbage collector) </li> <li><p>after 20 seconds the application stops and I get the following error:</p> <pre><code>Exception in thread "Animation Thread" java.lang.OutOfMemoryError: Java heap space at java.awt.image.DataBufferInt.&lt;init&gt;(Unknown Source) at java.awt.image.Raster.createPackedRaster(Unknown Source) at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source) at java.awt.image.BufferedImage.&lt;init&gt;(Unknown Source) </code></pre></li> </ul> <hr> <p>Here is my relevant Code regarding the visualization:</p> <pre><code>public boolean drawGrayscaleImage(){ //init PApplet and build JFrame GrayscalePApplet grayscalePApplet = new GrayscalePApplet (); grayscalePApplet.init(); this.grayscaleJFrame = this.initFrame(grayscalePApplet); //Set Uplink for PApplet and begin drawing grayscalePApplet.setGraphicP(this); return false; } </code></pre> <hr> <p>Here the drawing function from the Processing PApplet Class</p> <pre><code>public void draw(){ if(graphicP != null){ //creat the relevant image Buffers for java and Processing BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_BYTE_GRAY); PImage pimage = new PImage(image.getWidth(),image.getHeight(),PConstants.ARGB); //fill up the databuffer using a converted Kinect Grayscale Image DataBufferByte dataBuffer = new DataBufferByte(graphicP.getImage(ImageType.GRAYSCALE), this.imageWidth * this.imageHeight); Raster raster = Raster.createPackedRaster(dataBuffer,imageWidth, imageHeight, 8, null); image.setData(raster); //draw image to Processing image.getRGB(0, 0, pimage.width, pimage.height, pimage.pixels, 0, pimage.width); pimage.updatePixels(); image(pimage, 0, 0); // null everything to get Garbagecollection to work (?) image = null; pimage = null; dataBuffer = null; } } </code></pre> <p>How can I prevent that OutOfMemory Exception?<br> What may causes that exception? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload