Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

RecordStoreImpl - caching records

3 views
Skip to first unread message

Adrian Vintu

unread,
Jun 15, 2010, 2:57:06 AM6/15/10
to microemulato...@googlegroups.com
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

Bartek Teodorczyk

unread,
Jun 15, 2010, 3:31:26 AM6/15/10
to microemulato...@googlegroups.com
Hi,

I think your fix is OK. Already landed in repository. Thanks.

BR,
Bartek Teodorczyk

> --
> You received this message because you are subscribed to the Google Groups
> "microemulator-developers" group.
> To post to this group, send email to
> microemulato...@googlegroups.com.
> To unsubscribe from this group, send email to
> microemulator-deve...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/microemulator-developers?hl=en.
>

Reply all
Reply to author
Forward
0 new messages