You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old Persistent data storage - 2003-11-30, 09:25

Join Date: Mar 2003
Posts: 5
Location: Dragør, Denmark
slevinsen
Offline
Registered User
I have a serious problem with the Recordstore in the Nokia 3410. I am working on a simple client program for managing driving accounts for a small group of consultants. The prototype works fine in the emulator on the pc and on a Siemens phone, but it fails at very small amounts of data in the 3410. I have checked the size of the recordstore and the problem arises already at less than 10% used space. I have dropped an other project due to this problem, but if anyone has a good idea for a way around it, I would be very thankful.

Søren Levinsen
Reply With Quote

#2 Old 2003-11-30, 12:24

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
In what way does it fail?

Graham.
Reply With Quote

#3 Old 2003-11-30, 21:14

Join Date: Mar 2003
Posts: 5
Location: Dragør, Denmark
slevinsen
Offline
Registered User
Hi Graham, here is a code snippet that gives the troubles:

try{
RecordStore store = RecordStore.openRecordStore("trip", true);
RecordEnumeration enum = store.enumerateRecords(null, null, false);
.
.
.

The last line results in a java.lang.ArrayIndexOutOfBoundsException on the 3410 when I have 2 or more records in the store. If I reduce the size of the records I can store more records before I get the exception.
Søren
Reply With Quote

#4 Old 2003-11-30, 21:52

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Hi Søren,

Hmmm... that's quite serious. I don't recall anyone mentioning a bug in RMS on the 3410 before. (But then, few people use RMS that much.) I had problems with RMS on the Series 40, and the only way around was to change the way I used RMS quite dramatically. I haven't had the same problem as you on the 3410, but then I've only done a small amount of testing on the emulator, and I don't use the enumerator. Does this happen on the emulator also? Have you tried working without the enumerator?

Graham.
Reply With Quote

#5 Old 2003-12-01, 19:32

Join Date: Mar 2003
Posts: 5
Location: Dragør, Denmark
slevinsen
Offline
Registered User
Hi Graham,
thank you for your interest.

No, I do not get any exceptions neither in the emulator nor on the Siemens phone. It works quite fine there.

No, I have not tried to work without the enumerator in this particular case, but I dropped an earlier project due to problems that might very well be the same ones. In that project I stored a datastructure as XML in the first and only record in a Recordstore. It worked fine on the emulator and on a newer Nokia phone (I don't recall the number), but failed on the 3410 when I tried to save the data. In that case it was also the amount of data that trigerred the bug. Reducing the data to a small (and unusable) amount made the program run. I did quite a job debugging to be sure that it was not e.g. a memory problem.

I will now try to rewrite the code in different ways to try to get around the bug, but I think I will end up telling the customers not to use the Nokia 3410 phone for this application.

Søren
Reply With Quote

#6 Old 2003-12-01, 20:54

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Hi Søren,

My RMS problems involved deleteRecord()... I got around this by creating a separate record store for each record (!), and using deleteRecordStore() instead. Maybe you can store more data on the 3410 by using multiple record stores? (Though, if there are few potential users with this phone, it may not be worth the effort.)

Best of luck with your project,
Graham.
Reply With Quote

#7 Old 2003-12-01, 21:14

Join Date: Mar 2003
Posts: 5
Location: Dragør, Denmark
slevinsen
Offline
Registered User
Hi Graham,
thank you for the idea, I will try that immediately!
Søren
Reply With Quote

#8 Old 2003-12-01, 22:40

Join Date: Mar 2003
Posts: 5
Location: Dragør, Denmark
slevinsen
Offline
Registered User
Hi Graham - you're my man! It works, only problem is that it's a bit heavy to traverse the records (record stores), but that's not a show stopper.
Tanks a lot!
Søren
Reply With Quote

#9 Old can't delete RecordStore - 2004-01-09, 11:26

Join Date: Jun 2003
Posts: 12
fmx
Offline
Registered User
hi, grahamhughes, can you tell me how u delete the RecordStore, when I try to delete a recordstore, it always has error as "record store is still open", but I do make sure I have used close method to close it before delete. thanks.
Reply With Quote

#10 Old 2004-01-09, 22:47

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
The only way to delete a record store is:
Code:
RecordStore.deleteRecordStore ("myrecordstore");
This throws a RecordStoreException if the record store is open. It is very easy to leave a record store open, as you must have one "close" for each "open". If a single "close" request in your MIDlet gets missed (because an exception is thrown, caught and not reported), then the record store will remain open until your MIDlet ends.

You may experience other problems if record stores are left open. For this reason, I recommend that the record store is opened and closed in the same method, not left open for long periods of time. Then, a try-finally block can be used to ensure that the record store is closed under all circumstances.
Code:
try {
    RecordStore rs = RecordStore.openRecordStore ("data", true);
    try {
        // add, retrieve, update or delete records
    }
    finally {
        rs.closeRecordStore ();
    }
}
catch (RecordStoreException e) {
    // report exception
}
Without the try-finally, it would be possible for an exception to prevent the closeRecordStore() from being reached, and so the record store would remain open.

You should be able to test to see if a record store is open like this:
Code:
boolean isOpen (RecordStore rs) {
    boolean bOpen;
    try {
        rs.getSize ();
        bOpen = true;
    }
    catch (RecordStoreNotOpenException e) {
        bOpen = false;
    }
    return bOpen;
}
and you should be able to force a record store closed like:
Code:
void ensureClosed (RecordStore rs) {
    boolean bCouldBeOpen = true;
    while (bCouldBeOpen) {
        try {
            rs.closeRecordStore ();
        }
        catch (RecordStoreNotOpenException e) {
            // we know it isn't open now!
            bCouldBeOpen = false;
        }
    }
}
I hope this helps.

Graham.
Reply With Quote

#11 Old thank you very much, it's so helpful. - 2004-01-11, 13:55

Join Date: Jun 2003
Posts: 12
fmx
Offline
Registered User
how nice u r!
Reply With Quote

#12 Old 2005-06-08, 05:23

Join Date: Mar 2005
Posts: 249
lmtang
Offline
Regular Contributor
Been reading through old RMS posts and got curious about some stuff.

I know RMS memory limits are device specific. But is it limited per RecordStore or is it limited per Midlet or per midlet suite? Or is that device specific too?

One of the posts on this forum mentioned that updating a recordstore doesn't overwite the info, but rather appends it, so to effectively overwrite it, I'd have to recreate the recordstore and rewrite all the info. Is it still true?

Thanks.
Reply With Quote

#13 Old 2005-06-09, 22:34

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Limits will be device-specific. The limits given for Nokia Series 40s (60s have no specific limit) are per MIDlet suite.

The problem of records always appending: I think you're refering to a bug on older Series 60s where record stores seem to grow and grow until they choke the phone. It's not universally true. It's hard to find universal truths about RMS, as every device has a different implementation.

There are also some problems on older Series 40s that appear to relate to record store fragmentation - eventually the phone will reboot and when you restart the app you'll find the record store corrupt. This problem can be avoided by deleting and re-creating the record store.

Most devices will not require delete-and-re-create, and the vast majority of deployed applications do not do this. Of course, most deployed applications are games, and just store hiscore, sound on/off setting, and so on - not much data, and often packed in a single record.

Delete-and-re-create is worth considering if you're storing a large amount of data, and your data are volatile.

Graham.
Reply With Quote

#14 Old 2005-06-10, 04:14

Join Date: Mar 2005
Posts: 249
lmtang
Offline
Regular Contributor
Thanks for the reply. No universal truths... I should have guessed.

So for Series 60, if there's no specific limit, does that mean it just keeps filling up the record store until it runs out of all the space allocated for total RMS?
Reply With Quote

#15 Old 2005-06-12, 22:06

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Series 60's don't allocated a specific amount for RMS. So far as I know, it's just a file in the Symbian filesystem, so the maximum size is the amount free in the filesystem.

While people have reported problems with 7650s not releasing file-space when records are deleted, I have never seen this problem, so presumably it doesn't happen on newer Series 60s. If you have a Symbian Series 60 file explorer application, you should be able to find the RMS files and see how big they get.

Graham.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia