Only add to the memory array when using memoization, calculate the size of the object when using memorization. (+1 squashed commit)
Squashed commits:
[a8bb376] Adding memoization.