I've noticed that all Swing applications I've created seem to allocate new objects continuously.
Consider this small application:
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings({ "javadoc", "serial" })
public class SwingTest extends JFrame {
public static void main(String[] args) {
new SwingTest().setVisible(true);
}
public SwingTest() {
setTitle("SwingTest");
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setPreferredSize(new Dimension(400, 400));
setContentPane(panel);
pack();
}
}
I wouldn't expect it to consume much memory, but if I look at the heap graph in VisualVM I see memory usage increasing constantly, then resetting. What causes this?