[4229] in java-interest

home help back first fref pref prev next nref lref last post

Garbage Collection Poss Prob

daemon@ATHENA.MIT.EDU (Greg Gentling)
Wed Dec 13 23:35:26 1995

Date: Wed, 13 Dec 95 17:01:17 PST
From: "Greg Gentling" <GGentling@symantec.com>
To: java-interest@java.sun.com



Hey I ran into a little problem with offscreen images. In my update I create an
offscreen draw into it than draw onto the Graphics context. I noticed in Win95
that the create was not being disposed of. The darn thing just keeps eating the
resources up on every update. Here is the code frag below. 

What I ended up doing is moving the create offscreen calls outside the update,
and that works, but everytime the applet gets initialized the GDI goes down
another notch. I understand that after leaving the method shouldn't Java do the
clean-up? I noticed a dispose & finalize method's but to no avail that didn't
work either.... Bug maybe? or am I doing something wrong.


...Greg



public void update(Graphics g) {

    if ((size().height != lastS.height) || (size().width != lastS.width)) {
createParams(); }

   Image myImage = createImage(lastS.width, lastS.height);
   Graphics offScreen = myImage.getGraphics();

    offScreen.setColor(bgCo);

    offScreen.fillRect(0,0,lastS.width-1,lastS.height-1);

    offScreen.setColor(bgCo);

    offScreen.draw3DRect(2,2,lastS.width-5, lastS.height-5, true);

    offScreen.draw3DRect(3,3,lastS.width-7, lastS.height-7, true);

    offScreen.clipRect(5,4,lastS.width-10, lastS.height-8);

    offScreen..setColor(txtCo);

    offScreen.setFont(messageF);

    offScreen.drawString(message, messageX, messageY);

    g.drawImage(myImage,0,0,this);

    // tried this
    offScreen.dispose();
}




-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post