How memory is allocated in an int array

How much space does an int array take? Or how much space (in bytes) the int array consumes, which looks something like this:

 int[] SampleArray=new int[]{1,2,3,4};

Is the memory allocation language specific?

Thank you all

+4
source share
5 answers

Since you add a lot of language tags, I want to write for C #. In C #, it depends on the operating system.

For 32-bit, each inthas 4 bytes and 4 bytes also for an object reference, which makes 4 * 4 + 4 = 20 bytes

For 64-bit, each inthas 4 bytes and 8 bytes also for an object reference, which makes 4 * 4 + 8 = 24 bytes

# 5.0 . 22;

, , .NET 32- 64- .

+3

++, new int[4]{1, 2, 3, 4} , , sizeof(int)*4.

+2

Ques: ? , .. .. exp: SizeOf (INT) * 4

java int size 4 , : 4 * 4 = 16bytes

+1

, .

4 . 2 4 ( 4 ), , , sizeof (int).

( , - ), , MSB LSB ( 4 ).

+1

Java int [] array - , (8 x86) int (4 ), ints (arrayLength * 4).

   approxSize = 8 + 4 + 4 * arraylength 

. http://www.javamex.com/tutorials/memory/object_memory_usage.shtml

+1

All Articles