Sunday, 19 April 2009

s60 messaging: memory full

Since April 3rd my Nokia N82 (Symbian 9.2, S60 3rd Ed, FP1) is having problem with Messaging. Whenever I try to create a message, it shows error:

"Messaging: Memory full. Close some applications and try again."

Nokia N82 has more than 80MB of free RAM on startup and seems that Messaging doesn't use up all memory before the error. So, what's the problem? Let's get a look into the memory usage in Symbian application.

Each Symbian application must declare the amount of memory it uses. Stack size is fixed, and heap size is vary with maximum and minimum values. When a program shows "Memory full", it may used up all the heap it declared, even the phone still has some free memory. The maximum amount of memory that can be used is limited by the value set by the programmer of that application, not the device itself. That give no differences between E50 (12MB free RAM) and N82 (80+MB free RAM). That's so sad for users of this platform: why so stupid?

By the way, Symbian stores each message in a single file (with or without a sub-folder). Since the cluster size of Sybmian file system might be 4 to 16KB, storing a SMS, disregarding its size, might need 4KB of space. Do you see the problem? A thousand of SMS "OK" will take you 4MB on phone. I'm not going to discuss this problem further.

Now I want to fix this problem by archiving all my messages into a database (probably a SQL database file or multiple database files). So, I write a small program to read the messages. But my program crash with same error, even my stack = 64KB, heap = Min 4 MB, Max 64 MB. Here is when it crash:

The program gets entry to the local service (KMsvLocalServiceIndexEntryId) and finds 5 children. Then it scan each child and their children.
  1. In Inbox (0x1002), it finds 38 children, all are SMS.
  2. In Outbox (0x1003), there is none.
  3. In Draft (0x1004), 26 SMS found.
  4. In Sent (0x1005), 30 SMS found.
  5. In folder (0x1008), 25 children found.
Then my application scan these 25 children.
  1. First one (0x1009) is a folder with no content.
  2. Second one (0x0010000D), type unknown. Application get memory full error here.
So, what's wrong with it? What is 0x0010000D? I know it should be a message type since the ID start with 0x0010****. Anyway, still need some time to investigate.

No comments: