I've found our "memory leak".

Basic Config info:
  JDK 1.4.1_02
  Java 3D OpenGL 1.3.1
  GeForce 2 MX v 41.09 drivers

Related to Justin's bug report of excessive garbage collection with
picking (I believe he mentioned pick cones).  It seems picking using a
ray leaks memory (forced garbage collection does NOT reclaim it), but
picking using a long segment does NOT leak memory.

- John Wright
Starfire Research

This version of our terrain height check, using a ray leaks memory:

private BranchGroup structureObjects; // the terrain
private PickTool pickTool;
private Point3d startRay; // starting point of pickray
private Vector3d rayVector; // vector for pickray (which way it points)
private PickResult pr;
private PickIntersection pickIntersection;
private PickSegment pseg;
private Point3d iPoint; // intersection point returned by pick


/* This version seems to leak memory
  // check the height of terrain at a (x,z) location
        public float checkHeight(float nx, float nz) {
                highestHeight = -9000;
                pickTool = new PickTool(structureObjects);
                pickTool.setMode(PickTool.GEOMETRY);
                startRay = new Point3d((double) nx, (double) y+1.2+jumpHeight,
(double) nz); // allow a 1.2 meter "climb"
                rayVector = new Vector3d(0,-1.0,0);
                pickTool.setShapeRay(startRay,rayVector);
                pr = pickTool.pickClosest(); // pick result
                if ( (pr != null) ) {
                        if (pr.numIntersections() > 0) {
                                // what if we intersected more than one object?  And 
the "closest"
wasn't the highest y?
                                for (int loop = 0; loop < pr.numIntersections(); 
loop++) {
                                        pickIntersection = pr.getIntersection(loop); 
// get the pick
intersection
                                        if ( pickIntersection != null ) {
                                                iPoint = 
pickIntersection.getPointCoordinatesVW(); // definitely
should be VW!
                                                if (iPoint != null) {
                                                        tmpHeight = iPoint.y;
                                                        if ( tmpHeight > 
highestHeight) {
                                                                highestHeight = 
tmpHeight;
                                                        } // highest check
                                                } // iPoint null check
                                        } // null check
                                } // checking for
                                return (float) highestHeight+jumpHeight;
                        } // end of pr.numIntersections
                } // end if pr null
                return y; // nothing below us!  Return what we came in with!
        } // end of checkHeight
*/
- - - - - - - - - - - - - - - - - - - - -

This version using a LONG pick segment appears to work fine (several
hours of running with no detectable leak).

// attempt to fix memory leak
// check the height of terrain at a (x,z) location
        public float checkHeight(float nx, float nz) {
                highestHeight = -9000;
                pickTool = new PickTool(structureObjects);
                pickTool.setMode(PickTool.GEOMETRY);

//              startRay = new Point3d((double) nx, (double) y+1.2+jumpHeight,
(double) nz); // allow a 1.2 meter "climb"
//              rayVector = new Vector3d(0,-1.0,0);
//              pickTool.setShapeRay(startRay,rayVector);

                pseg = new PickSegment(new Point3d(nx,y+1.0f,nz),new
Point3d(nx,y-9001.0f,nz));
                pickTool.setShape(pseg, new Point3d(x,y+1,z));

                pr = pickTool.pickClosest(); // pick result
                if ( (pr != null) ) {
                        if (pr.numIntersections() > 0) {
                                // what if we intersected more than one object?  And 
the "closest"
wasn't the highest y?
                                for (int loop = 0; loop < pr.numIntersections(); 
loop++) {
                                        pickIntersection = pr.getIntersection(loop); 
// get the pick
intersection
                                        if ( pickIntersection != null ) {
                                                iPoint = 
pickIntersection.getPointCoordinatesVW(); // definitely
should be VW!
                                                if (iPoint != null) {
                                                        tmpHeight = iPoint.y;
                                                        if ( tmpHeight > 
highestHeight) {
                                                                highestHeight = 
tmpHeight;
                                                        } // highest check
                                                } // iPoint null check
                                        } // null check
                                } // checking for
                                return (float) highestHeight+jumpHeight;
                        } // end of pr.numIntersections
                } // end if pr null
                return y; // nothing below us!  Return what we came in with!
        } // end of checkHeight

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to