0

This simple program, and memory (Private Working Set by Task manager) grows by resizing its frame. 32MB (initially) to 140MB and more if I persistently resizing the frame. Why does this happen and is this normal for a Java program ?

import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class TestSwing {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            frame.setVisible(true);
        });
    }
}

I did the same for SWT and JavaFX simple one frame program. Memory growth is very slow as compared to Swing but it seems it grows steadily.

I also did the same for notepad.exe's frame but the memory didn't grow.

I used VisualVM to watch the JVM heap but heap size did not change. So maybe the problem is native memory that GUI library uses.

enter image description here [ Private Working Set : 31MB (initial) -> 192MB (last) ]

Environment : Windows Vista / Java 8 update 66

Nyabkun
  • 56
  • 1
  • 4

0 Answers0