Skip to content

Weird measurements #7

@ittayd

Description

@ittayd

(sorry the example is in Scala)

scala> case class Person(name: String, surname: String)
defined class Person

scala> objectexplorer.MemoryMeasurer.measureBytes(Person("", ""))
res1: Long = 64

scala> objectexplorer.MemoryMeasurer.measureBytes(Person("h", ""))
res2: Long = 112

scala> objectexplorer.MemoryMeasurer.measureBytes(Person("h", "h"))
res3: Long = 72

In the first line I declare a class with two properties. In the second I measure the size of an object of that class that is instantiated with 2 empty strings. In the third, an object with 1 character string and empty string. The size is indeed larger. Now I try with an object of two such strings. The size becomes less?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions