Scala objects follow roughly the same rules as Java objects, so any information about them is accurate. Here is one source that at least is mostly suitable for 32-bit JVMs. (64-bit JVMs use 8 bytes per pointer, which usually works with extra overhead of 4 bytes plus 4 bytes per pointer, but may be less if the JVM uses compressed pointers, which, by default, I now think.)
I assume a 64-bit machine without compressed pointers (worst case); then a Tuple3
has two pointers (16 bytes) plus plus Int
(4 bytes) plus object overhead (~ 12 bytes), rounded to the nearest 8 or 32 bytes, plus an additional object (8 bytes) as a stub for the non-specialized version of Int
. (Unfortunately, if you use primitives in tuples, they take up even more space than using wrapped versions.). String
- 32 bytes, IIRC, plus an array for data of 16 plus 2 per character. java.sql.Timestamp
needs to save a Long
pair (I think it is), so 32 bytes. Everything is said that it is about 120 bytes plus two per character, which is ~ 160 bytes for ~ 20 characters.
Alternatively, see this answer for a way to measure the size of your objects directly. When I measure it this way, I get 160 bytes (and my score above was adjusted using this data to fit, I used to have a few small errors).
source share