Skip to content

Instantly share code, notes, and snippets.

@SergejIsbrecht
Created February 10, 2020 13:34
Show Gist options
  • Save SergejIsbrecht/8012ad0acf0764b63e15ad6f94189ff4 to your computer and use it in GitHub Desktop.
Save SergejIsbrecht/8012ad0acf0764b63e15ad6f94189ff4 to your computer and use it in GitHub Desktop.
java_malloc
// https://www.javaspecialists.eu/archive/Issue142.html
int[] primitiveIntArray = new int[1000];
primitiveIntArray[0] = 256;
primitiveIntArray[1] = 256;
primitiveIntArray[2] = 256;
primitiveIntArray[3] = 256;
primitiveIntArray[4] = 256;
measureSize(primitiveIntArray);
Integer[] iArray = new Integer[1000];
iArray[0] = 256;
iArray[1] = 256;
iArray[2] = 256;
iArray[3] = 256;
iArray[4] = 256;
measureSize(iArray);
// output:
// int[], shallow=4016, deep=4016
// Integer[], shallow=4016, deep=4016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment