• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutOfMemoryException ??

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have one method which is called 4000 times (say).
I am getting OutOfMemoryException on calling the method for 4000 times.
Is there any error in my method .
Is there any way to take care of OutOfMemoryException in my method??
Please suggest.
My method is as follows.
protected void replaceSpecificComboBoxEditor(List l, int row, int column)
{
DefaultCellEditor editor = new DefaultCellEditor
(new JComboBox(l.toArray()));
removeCellEditor(row, column);
addCellEditor(row, column, editor);
}
I have also tried the following .Still the problem is coming .
protected void replaceSpecificComboBoxEditor(List l, int row, int column)
{
DefaultCellEditor editor = new DefaultCellEditor
(new JComboBox(l.toArray()));
removeCellEditor(row, column);
addCellEditor(row, column, editor);
//added the following lines.
editor = null;
System.gc();
}
Is there any way to force the garbage collector to collect unused object references ?
TIA for the suggestions.
Raj
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Don t know if it would help much, but you could catch the exception using

hope it helps, could anyone comment on it?
Daniel
[ February 19, 2004: Message edited by: Daniel Atrei ]
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure, but here is what I guess:
You created 4000 JComboBoxes, and CellEditors.
I don't know the methods 'removeCellEditor' and 'addCellEditor', but I guess the latter one puts it to a place in the GUI and the first one takes it away from the GUI.
But it is not deleted by removing.
So I would try remove the CellEditor first, then delete the Components, which it was made from, (=null) and since we need a reference to the old Objects, to set them to null, we create two private Memberobjects.

[ February 19, 2004: Message edited by: Stefan Wagner ]
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can set the size fo memory which the jvm use
 
reply
    Bookmark Topic Watch Topic
  • New Topic