-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.1.8
-
x86
-
windows_2000
We have a component that overrides paint method in which we does several
Graphics.drawString(). The problem is that every time paint is called the amount
of memory usage increases.
I'm using windows 2000, but I also see the problem in Windows 98. I'm watching memory usage from the task manager, processes tab.
In the example included below, when you click the button memory raises 4k.
If I add more drawString, like our product does, the amount is bigger.
You can try the test case, and clcik fast and several times the repaint button.
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class TestDrawString
extends JPanel
implements ActionListener
{
public void paint(Graphics g){
super.paint(g);
g.drawString("Hola",5,25);
g.drawString("Hola1",5,45);
g.drawString("Hola2",5,55);
g.drawString("Hola3",15,25);
g.drawString("Hola4",15,45);
g.drawString("Hola5",15,55);
g.drawString("Hola6",25,25);
g.drawString("Hola7",25,45);
g.drawString("Hola8",25,55);
g.drawString("Hola9",35,25);
g.drawString("Hola10",35,55);
}
public static void main(String args[]){
JFrame f = new JFrame("Test");
f.getContentPane().setLayout(new FlowLayout());
TestDrawString s = new TestDrawString();
s.setLayout(new FlowLayout());
JButton b = new JButton("Repaint");
b.addActionListener(s);
Dimension d = new Dimension(60,60);
s.add(Box.createRigidArea(d));
s.add(b);
f.getContentPane().add(s);
f.pack();
f.setVisible(true);
}
public void actionPerformed(ActionEvent e){
for(int i=0; i<100; i++)
repaint();
}
}
Graphics.drawString(). The problem is that every time paint is called the amount
of memory usage increases.
I'm using windows 2000, but I also see the problem in Windows 98. I'm watching memory usage from the task manager, processes tab.
In the example included below, when you click the button memory raises 4k.
If I add more drawString, like our product does, the amount is bigger.
You can try the test case, and clcik fast and several times the repaint button.
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class TestDrawString
extends JPanel
implements ActionListener
{
public void paint(Graphics g){
super.paint(g);
g.drawString("Hola",5,25);
g.drawString("Hola1",5,45);
g.drawString("Hola2",5,55);
g.drawString("Hola3",15,25);
g.drawString("Hola4",15,45);
g.drawString("Hola5",15,55);
g.drawString("Hola6",25,25);
g.drawString("Hola7",25,45);
g.drawString("Hola8",25,55);
g.drawString("Hola9",35,25);
g.drawString("Hola10",35,55);
}
public static void main(String args[]){
JFrame f = new JFrame("Test");
f.getContentPane().setLayout(new FlowLayout());
TestDrawString s = new TestDrawString();
s.setLayout(new FlowLayout());
JButton b = new JButton("Repaint");
b.addActionListener(s);
Dimension d = new Dimension(60,60);
s.add(Box.createRigidArea(d));
s.add(b);
f.getContentPane().add(s);
f.pack();
f.setVisible(true);
}
public void actionPerformed(ActionEvent e){
for(int i=0; i<100; i++)
repaint();
}
}