How many bytes of memory does a java.util.Date object use?

后端 未结 7 2108
故里飘歌
故里飘歌 2020-12-10 12:15

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

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 12:25

    Use the primitive long ?

    It is not an object, so less space, and dates can be expressed as a long value. Then convert back and forth between Date and long when you want to store the dates and use less memory.

提交回复
热议问题