Hi everybody,
I am using an Offscreen Canvas for printing my view, the problem is that
the memory increases every time I render the offscreen canvas for a new
print, but it is never decreases. After the second print my application
dies.
I am working on Windows NT SP 6, with an Elsa Gladiac MX JDK 1.3.1 and
Java3D 1.2 ( I tried updating to Java3D 1.2.1 with no success).
What can I do to decrease the memory?
Thanks for your help in advance Desiree
Here are the relevant parts of my code:
I am using the offscreen example from the demos:
class OffScreenCanvas3D extends Canvas3D {
OffScreenCanvas3D(GraphicsConfiguration graphicsConfiguration,
boolean offScreen) {
super(graphicsConfiguration, offScreen);
}
BufferedImage doRender(int width, int height) {
BufferedImage bImage =
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
//new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
ImageComponent2D buffer =
new ImageComponent2D(ImageComponent.FORMAT_RGBA, bImage);
//new ImageComponent2D(ImageComponent.FORMAT_RGB, bImage);
setOffScreenBuffer(buffer);
renderOffScreenBuffer();
waitForOffScreenRendering();
bImage = getOffScreenBuffer().getImage();
return bImage;
}
public void postSwap() {
// No-op since we always wait for off-screen rendering to complete
}
}
This is the method, where I create my offscreen canvas, I tried to
collect the objects and run the garbage collector, without any success:
/**
* Printing in Java3D needs an additional Canvas with the view, this
* Canvas is created in this method.
*/
public void createPrintCanvas() {
// Background
createBackgroundNode(Color.white);
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
OffScreenCanvas3D offScreenCanvas3d = new
OffScreenCanvas3D(config,true);
// Set the off-screen size based on a scale factor times the
// on-screen size
Screen3D sOn = c.getScreen3D();
Screen3D sOff = offScreenCanvas3d.getScreen3D();
Dimension dim = sOn.getSize();
dim.width *= OFF_SCREEN_SCALE;
dim.height *= OFF_SCREEN_SCALE;
sOff.setSize(dim);
sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth() *
OFF_SCREEN_SCALE);
sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight() *
OFF_SCREEN_SCALE);
// attach the offscreen canvas to the view
u.getViewer().getView().addCanvas3D(offScreenCanvas3d);
Point loc = c.getLocationOnScreen();
offScreenCanvas3d.setOffScreenLocation(loc);
dim = c.getSize();
dim.width *= OFF_SCREEN_SCALE;
dim.height *= OFF_SCREEN_SCALE;
addBackgroundNode();
//Background testBack = new Background(new
Color3f(1.0f,1.0f,1.0f));
bImage = offScreenCanvas3d.doRender(dim.width, dim.height);
removeBackgroundNode();
u.getViewer().getView().removeCanvas3D(offScreenCanvas3d);
offScreenCanvas3d = null;
config = null;
sOn = null;
sOff = null;
System.gc();
System.runFinalization();
}
oooooooooooooooooooooooooooooooooooooooooooooooo
Desiree Hilbring
Institut fuer Photogrammetrie und Fernerkundung
Universitaet Karlsruhe, Germany
email: [EMAIL PROTECTED]
# 0721 6083676
oooooooooooooooooooooooooooooooooooooooooooooooo
===========================================================================
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".