FileConnection Blackberry memory usage

Posted by Dean on Stack Overflow See other posts from Stack Overflow or by Dean
Published on 2010-06-09T02:03:20Z Indexed on 2010/06/09 2:12 UTC
Read the original article Hit count: 201

Filed under:
|
|
|

Hello, I'm writing a blackberry application that reads ints and strings out of a database. This is my first time dealing with reading/writing on the blackberry, so forgive me if this is a dumb question.

The database file I'm reading is only about 4kB

I open the file with the following code

fconn = (FileConnection) Connector.open("file_path_here", Connector.READ);
if(fconn.exists()==false){fconn.close();return;}
is = fconn.openDataInputStream();
while(!eof){
    //etc...
}
is.close();
fconn.close();

The problem is, this code appears to be eating a LOT of memory. Using breakpoints and the "Memory Statistics" view, I determined the following:

  • calling "Connector.open" creates 71 objects and changes "RAM Bytes in use" by 5376
  • calling "fconn.openDataInputStream();" increases RAM usage by a whopping 75920

Is this normal? Or am I doing something wrong? And how can I fix this? 75MB of RAM is a LOT of memory to waste on a handheld device, especially when the file I'm reading is only 4kB and I haven't even begun reading any data! How is this even possible?

© Stack Overflow or respective owner

Related posts about java

Related posts about blackberry