Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 05:09, 30 July 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Record update with RecordStore.setRecord() fails in Series 40 (Known Issue)

From Wiki
Jump to: navigation, search
Article Metadata
Created: User:Technical writer 1 (21 Aug 2008)
Last edited: hamishwillee (30 Jul 2013)


RecordStore.setRecord() fails to reuse the existing reserved memory, resulting in 'Out of Memory exception' application error notification or the program exiting directly without any notification at all.

How to reproduce

  1. Implement a test MIDlet using the following code:
     import javax.microedition.midlet.*;
    import javax.microedition.rms.RecordStore;
    import javax.microedition.lcdui.*;
    public class ErrorDemo extends MIDlet {
    //.. pauseApp() and destroyApp() excluded for code brevity
    protected void startApp() throws MIDletStateChangeException {
    boolean newrun = false;
    Form f = new Form("Debug");
    Display.getDisplay( this ).setCurrent( f );
    try {
    RecordStore r = RecordStore.openRecordStore( "dummy" , true );
    int cntr, cntr2;
    byte[] empty = new byte[512];
    if( r.getNextRecordID() < 2 ) { // empty RMS?
    newrun = true;
    cntr = 1;
    while( r.getSizeAvailable() > 1024 ) {
    r.addRecord(empty, 0, 512); // Fill the RMS
    } else cntr = r.getNextRecordID() - 1;
    f.append( "Replacing those records" );
    StringItem i = new StringItem( "Record No", "" );
    f.append( i );
    // Replacing all of the records
    for( cntr2=1; cntr2<cntr; cntr2++ ) {
    i.setText( String.valueOf( cntr2 ) );
    if( !newrun ) Thread.sleep(1000);
    r.setRecord(cntr2, empty, 0, 512);
    } catch( Exception e ) {}
    f.append("Done"); // Record (re)placing finished.
    try { Thread.sleep(5000); } // Waiting for a while before exiting the MIDlet.
    catch( Exception e ){}
  2. Launch the MIDlet, let it write the records, and exit the MIDlet.
  3. Launch the MIDlet again. The described issue occurs.


This issue has been fixed starting from Series 40 5th Edition, Feature Pack 1.

This page was last modified on 30 July 2013, at 05:09.
54 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.