Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example Reference and Heap Usage
// Technical Note: We can't add any strings to the debug logs
// because strings go in to a "string pool", which affects
// heap size for each non-unique string.
// Base heap
// The "symbol table" has a new entry added, +0 heap
// i is defined, no value (heap does not change)
Integer i;
// i now has a reference to an Integer 5 on the heap, +8 heap
i = 5;
// j contains a reference to i, +0 heap
// If it were not a reference, it would have been +8 heap
Integer j = i;
// j now has its own value, +8 heap
j = 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment