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
New Developer
Posts: 20
Registered: ‎05-18-2012
My Device: 9800
My Carrier: MTS

Application can't use RAM more then 128MB?

My BB9800 have 350MB free RAM after reboot. When ,my app try to use more then 128MB of RAM(several big Arrays) i get OutOfMemory in console and then "552 RESET". Is it OK? IS 128MB limit of RAM  for 1 application?

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones

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

Re: Application can't use RAM more then 128MB?

I am not aware of there being a limit to the amount of RAM a single application holds.

 

However what is more likely to be an issue is the size of the largest contiguous block of RAM that the system can find for you.  If you are allocating a large array, then the system needs to find that amount of contiguous space which might be more of a problem.

 

There are other compounding issues as well.  If you are persisting these then at times (as I understand it) you can have three versions of the array around - one persisted - one in flash ready to be persisted, and one in RAM that is being used.  In addition, with every Object there are pointers associated, so a large array of String objects takes up a significant amount of memory even when empty, because of al the overhead of the Object pointers that Java needs to maintain.

 

But I suspect in this case it is just the contiguous space requirement.  We would need to understand how you are using this memory to see if there was an alternate way to work with your data. 

New Developer
Posts: 20
Registered: ‎05-18-2012
My Device: 9800
My Carrier: MTS

Re: Application can't use RAM more then 128MB?

I tried to create arrays byte[4096*1024] in loop. A am monitoring BlackBerry Memory Statistics View. Allocated memory is always equals 128MB. When i have FREE memory less then arrays size i get error out of memory.  So the question is, why i always get 128MB of allocated  memory, when i have 350 MB free RAM on my BB9800?

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones

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

Re: Application can't use RAM more then 128MB?

Have you tested this on the Simulator?  Do you see the same thing?

Highlighted
New Developer
Posts: 20
Registered: ‎05-18-2012
My Device: 9800
My Carrier: MTS

Re: Application can't use RAM more then 128MB?

[ Edited ]

I made RAM stats(Memory.getRAMStats()) before creating array. Look at results:


[0.0] [Memory stats] used:59638 kB / allocated:119043 kB / free:7193 kB
[0.0] Try to create temp buffer with size=4194304
tmpBuf=new Byte[1024*4096];
Got exception java.lang.OutOfMemoryError

next loop
[0.0] [Memory stats] used:58923 kB / allocated:119043 kB / free:7193 kB
[0.0] Try to create temp buffer with size=4194304
Got exception java.lang.OutOfMemoryError
tmpBuf=new Byte[1024*4096];

 

next loop
[0.0] [Memory stats] used:58872 kB / allocated:119042 kB / free:7194 kB
[0.0] Try to create temp buffer with size=4194304
Got exception java.lang.OutOfMemoryError

tmpBuf=new Byte[1024*4096];

 

next loop
[0.0] [Memory stats] used:58825 kB / allocated:118946 kB / free:7290 kB
[0.0] Try to create temp buffer with size=4194304
tmpBuf=new Byte[1024*4096];

Got App Error 552
OutOfMemoryError
After this my BB9800 hung. Only reboot

 

So i can'd understand what type of memory is out of?

Tried the same test with simulator 8520:

 

[0.0] [Memory stats] used:23618 kB / allocated:49148 kB / free:1548 kB
[0.0] Try to create piece buffer with size=4194304

Got exception java.lang.OutOfMemoryError

 

 

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones