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?

Here is the result of profiling your code on my machine (OpenJDK 1.6.0_22 64 bits on linux 3.1.1, using Netbeans profiler)
I suggest you to find out what those allocated objects are. You can do this by making memory snapshots and comparing them.
Note that the Netbeans profiler is the same codebase than VisualVM.