-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.1
-
None
-
sparc
-
solaris_2.5.1
Name: mc57594 Date: 03/10/97
Here is code to reproduce the problem I have discovered. More
information follows the code, so read on.
----- START CODE -----
import java.lang.*;
import java.awt.*;
class TestFont extends Canvas
{
public void paint(Graphics g)
{
Font font;
// Set up the new font.
font = new Font("Helvetica", Font.PLAIN, 12);
g.setFont(font);
// Draw something.
g.drawString("Font Test Program!!!", 50, 50);
}
// Return the preferred size for this component.
public Dimension getPreferredSize()
{
return getMinimumSize();
}
// Return the minimum size for this component.
public Dimension getMinimumSize()
{
return new Dimension(300, 100);
}
public static void main(String args[])
{
Frame f;
TestFont tf;
f = new Frame("Font Test Program");
tf = new TestFont();
f.add(tf);
f.pack();
f.show();
while (true)
{
try {
Thread.sleep(100);
} catch (InterruptedException ie) {}
tf.repaint();
}
}
}
----- END CODE -----
If this program is compiled under Java 1.1 (final) and run, it
will use up virtual memory resources. To see this, I also run
the command 'vmstat 1' in another window. It becomes obvious
that virtual memory is definitely decreasing while the program is
running, and that it decreases at a rate related to the frequency
that the canvas is repainted. When virtual memory hits 0, the
machine will crash. How badly the machine crashes depends; I've
had machines become unusable and have to be power-cycled, or
sometimes the windowing system just goes down, or sometimes the
program just seg-faults and core dumps. It depends on the setup
of the system, it seems.
Note that if the call to Graphics.setFont() is not called, no
leaking occurs. This indicates to me that Graphics.setFont()
keeps around unneccessary references to the passed-in Font
objects, but I don't have any solid idea of how it all works, of
course. :)
company - Caltech Seismology Lab , email - ###@###.###
======================================================================
- duplicates
-
JDK-4068618 Motif FontPeer needs to be disposed to prevent memory leak
-
- Resolved
-