I've created a Minesweeper game that generates a 2-D array of JButtons every time a new game is started. The problem is that memory usage increases exponentially(JProfiler says it's the JButtons). It seems that not only are the old Jbutton instances being kept in memory, but the number of instances double. How can I tell it to get rid of the old JButtons? Thanks
private JButton[][] but;
but = new JButton[row][col];
for (int i = 0;i<row;i++)
{
for (int j = 0;j<col;j++){
but[i][j]= new JButton();
but[i][j].setName(i+":"+j);
mine.add(but[i][j]);
but[i][j].addMouseListener(this);
}
}