I need to store a large amount of dates (potentially large enough that the amount of heap space used is a concern so please, no lectures on premature optimization), and I\'m
I tried a manual calculation based on the rules here: http://www.javamex.com/tutorials/memory/object_memory_usage.shtml and checking the source code of the Date object in Java 7 the memory usage.
Object overhead: 8 bytes => 8 bytes
+ 1 long fastTime: 8 bytes => 16 bytes
+ 1 reference cdate: 4 bytes => 20 bytes
Rounded up to nearest multiple of 8 => 24 bytes
Maybe I'm missing something in the calculation or the tools that were used in other answers that gave a result of 32 were including the references to the dates themselves in the calculation?