Skip to main content

Heap or LAM

2 replies [Last post]
peppeme
Offline
Joined: 2007-05-30
Points: 0

byte[] data = new byte[len];

Take space in heap or in LAM?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
terrencebarr
Offline
Joined: 2004-03-04
Points: 0

The pointer to the array object (data) will be allocated either on the variable stack (if declared in a method block) or in the class data (if declared as a member variable). The actual array itself (byte[len]) will be allocated on the heap.

What does LAM stand for?

-- Terrence

peppeme
Offline
Joined: 2007-05-30
Points: 0

LAM stands for Large Array Memory
http://cellphonesclub.com/wp/2006/02/12/j2me-heap/.

So if the data will allocated on the heap,
I can check if there are free space for allocate a data of "len" size.

System.gc();
int freeMem = Runtime.getRuntime().freeMemory();
if (freeMem > len) new byte[len]
else "There isn't sufficent free memory"

Is right?