Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 105
Registered: ‎07-24-2008
My Device: Not Specified

Persistent storage

Hi

I need to store about 1 GB of data on Bold. I will have many records. Will store it in Persistant store in an array of records.

 

Is it possible ? How much time will it take to store and retrieve that amount of data ?

 

Please Let me know any pointers.

 

Regards,

Abhijit Chandekar

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Persistent storage

[ Edited ]

Comment removed - misread 1GB as 1MB. Please review next post.

Message Edited by peter_strange on 01-22-2009 10:00 AM
New Developer
Posts: 38
Registered: ‎01-21-2009
My Device: Not Specified

Re: Persistent storage

Erm I doubt you can use persistent memory for this, since there is only something like 128M total available for the system, nor would you be able to use the rest of the internal memory (about 890M), the only option would be a file on a SD card as far as I'm aware.
Developer
Posts: 105
Registered: ‎07-24-2008
My Device: Not Specified

Re: Persistent storage

Peter, i created a class having an image of 150 KB and created 10000 objects of this class. so it should be ideally 1.5GB.

 

I could store the10000 objects on the device. Not sure how it was managed. Even the speed of operation was good.

 

Kindly suggest !

 

Abhijit

 

 

 

 

Developer
Posts: 170
Registered: ‎01-17-2009
My Device: 9630

Re: Persistent storage

Why not create an instance of the image and pass it as a parameter to each of these 10,000 objects. Also why do you have 10,000 objects? Your application will run incredibly slow and I'm sure that RIM would reject it from the storefront if you tried submitting it...
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Persistent storage

@Abhijit: Not sure what you are asking.  I think you are saying that you created 10,000 objects each of which is 150 KB and it worked fine - and suggesting this proves the SD Card is used.  I would need to try that for myself to be convinced.

 

@gregzav: I wouldn't be too concerned about that number of Objects, As a test, a while ago on an old device, I put 15,000 rows of data, and it worked fine once they were up there.  It is the creation and destroying that takes the time.

Developer
Posts: 105
Registered: ‎07-24-2008
My Device: Not Specified

Re: Persistent storage

Peter-

I created a class "MyClass", that has 2 fields of Class EncodedImage. Each of my image is of 75kb, this means if i create an instance of the MyClass, then the instance would be atleast of 150 kb. In a for loop i created 10000 such instances.

All these instances kept in an array would make a size of 1.5 GB.

 

I kept this array in persistent memory. This means i kept 1.5 GB of data in the persistent store.

 

Also i have no SD card on device, then where is this data being stored.?

 

class MyClass{

EncodedImage img1,img2;

public MyClass()

{

// instanciate EncodedImage img1 and img2 in constructor

}

 

for(int i=0;i<=10000;i++)

{

//instantiate MyClass and keep the object in array.

}

create 10000 objects of MyClass and keep those objects in an array.

 

Abhijit

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Persistent storage

[ Edited ]

I suspect you are misunderstanding how the Object model Persistent store works.

 

Each of your MyClass instances, contains a reference to two EncodedImages.  However since they all use the same EncodedImages, the EncodedImages will only be stored in Persistent Storage once.  So your Persistent store actually contains 10,000 MyClass instances plus 2 EncodedImage instances, not 10,000 MyClass instances and 20,000 EncodedImage instances.

 

If you really want to test this, you are going to have to create unique Objects for each 'row' you are adding.  For example, do something like the following:

 

Vector bigStore = new Vector(10000)l

for ( int i = 0; i < 10000; i++ ) {

byte [] chunk = new byte [20*1024];

Arrays.fill(chunk, (byte) 0x'31');

bigstore.addElement(chunk);

}

 

// now try to persist bigStore.

 

Note: Just edited the code, so that it will run on a Bold, but not be able to be persisted on a Bold.  I beleive the Bold has 128MB Flash, and 1 GB RAM (which might be shared) - this code is intended to use about 200 MB, so should run in RAM, but be too big to be persisted.  However I have NOT tested this code, and would not recommend running it on a device.  Use at your own risk.  If I get round to trying it, or get input from someone who has, I will update this comment.  Cheers

Message Edited by peter_strange on 02-02-2009 10:35 AM
Developer
Posts: 16,578
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Persistent storage

somehow the idea of being willing to store the same two images tenthousand times scares me
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 558
Registered: ‎11-25-2008
My Device: Not Specified

Re: Persistent storage

A better design would be to store it in a file on the SD card and read it in real time. Note that that is plenty fast to be visible as an animation or whatever you are doing.

 

Note that I just went through hell and back figuring out the memory internals and have it finally solved. This may be of use to you.

 

There is 1GB of fast flash storage internally. 128MB is used for apps and 872MB is used as device memory (I think persistent storage gets put in there). Remember rewriting flash thousands of time is not wise as this flash has 100K write cycles before it dies (thats reduced through wear levelling algorithms), but count on the number of times you can do that being limited. There is also 128MB of internal RAM. This is where data goes when you allocate memory (non-persistant storage). So, if you want to do this, I'd recommend you use non-persistant storage in conjunction with a file on the SD card.

 

Good luck.