PShape problem loading hi-poly OBJ

edited September 2014 in How To...

Hi there, i'm coding a simple OBJ viewer using PShape. It is fine with models up to 165K polygons, but if I try loading an OBJ with more tha 300K polygons it crashes. Is there any way to handle this? BTW here's the code:

import processing.opengl.*;
import peasy.*; 
PeasyCam cam;

PShape model;

float ry;

public void setup() {
  size(1280, 720, OPENGL);
  model = loadShape("lowResGeo165.obj");
  cam = new PeasyCam(this, width);

public void draw() {
  ambientLight(102, 102, 102);
  directionalLight(126, 126, 126, 0, 0, -1);
  directionalLight(126, 126, 126, 0, 0, 1);

  translate(width/2, height/2 + 100, 0);

  ry = 0;


  • add after line 11


    this will show you whether the loadShape has worked - if it's null then you can check for that. if it throws an exception you can catch that.

    we can't test your code - the problem is the obj file which you don't supply...

  • I'm using the same obj, the lowres one loads fine the hires crashes. Here's the error I'm getting:

    java.lang.OutOfMemoryError: GC overhead limit excedeed

    java.lang.RuntimeException: java.lang.OutOfMemoryError: GC overhead limit exceeded at com.jogamp.common.util.awt.AWTEDTExecutor.invoke( at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread( at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread( at at at at processing.opengl.PJOGL.requestDraw( at processing.opengl.PGraphicsOpenGL.requestDraw( at at Source) Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded at processing.opengl.PGraphicsOpenGL$InGeometry.allocate( at processing.opengl.PGraphicsOpenGL$InGeometry.( at processing.opengl.PGraphicsOpenGL.newInGeometry( at processing.opengl.PShapeOpenGL.( at processing.opengl.PGraphics3D.createShapeImpl( at processing.opengl.PShapeOpenGL.createShape3D( at processing.opengl.PShapeOpenGL.copyGroup3D( at processing.opengl.PShapeOpenGL.createShape3D( at processing.opengl.PGraphics3D.loadShapeImpl( at processing.opengl.PGraphicsOpenGL.loadShape( at processing.core.PApplet.loadShape( at obj_viewer_003.setup( at processing.core.PApplet.handleDraw( at processing.opengl.PJOGL$PGLListener.display( at jogamp.opengl.GLDrawableHelper.displayImpl( at jogamp.opengl.GLDrawableHelper.display( at$ at jogamp.opengl.GLDrawableHelper.invokeGLImpl( at jogamp.opengl.GLDrawableHelper.invokeGL( at$ at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$ Source) at java.awt.EventQueue$ Source) at Method) at$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

  • If you need I can provide the obj

  • edited September 2014 Answer ✓

    Try going to File > Preferences and increasing your maximum available memory.

  • @amnon, thanks, that worked

Sign In or Register to comment.