Skip to main content

Heap or LAM

2 replies [Last post]
Joined: 2007-05-30

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.
Joined: 2004-03-04

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

Joined: 2007-05-30

LAM stands for Large Array Memory

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

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

Is right?