Hi Bartek,
I have seen that the RecordStoreImpl caches the read records in this.records hashtable.
public void readRecord(DataInputStream dis) throws IOException
{
...
byte[] data = new byte[dis.readInt()];
dis.read(data, 0, data.length);
this.records.put(new Integer(recordId), data);
}
I think this is pretty unexpected unexpected behavior. I was profiling my app and I saw a huge chunk of heap memory was wasted because I was reading images from the RMS.
I have added a patch in closeRecordStore.
public void closeRecordStore()
throws RecordStoreNotOpenException, RecordStoreException
{
if (!open) {
throw new RecordStoreNotOpenException();
}
if (recordListeners != null) {
recordListeners.removeAllElements();
}
recordStoreManager.fireRecordStoreListener(ExtendedRecordListener.RECORDSTORE_CLOSE, this.getName());
// FIXME check this
this.records.clear();
open = false;
}
I think you should either patch or document that the read records are cached (I apologize if this is already documented somewhere and I did not see it). This could be a very big issue for big lists.
(My patch has not been fully tested at all, btw)
Hope this is a helpful tip,
All the best,
Adrian Vintu
http://adrianvintu.com