Closed l15k4 closed 7 years ago
Scala currently stores arrays of value classes in a boxed representation, and, I'd assume, that by the time scala-native comes, there's not much one can do with it.
Dotty had a prototype in works that would support storing arrays of value classes efficiently https://github.com/lampepfl/dotty/pull/1228
Good to know, thanks!
@DarkDimius btw can you see a reason why offheap.Array
is not Allocatable
? So that one could have offheap array of arrays ? Size is known upfront for memory alignment, so it could be doable, right?
It would help for building other collection types like Map
Hey,
I think that the value classes that hold allocation address put significant on-heap memory and GC overhead :
This ends up with
java.lang.OutOfMemoryError: GC overhead limit exceeded
even if I use-Xmx4096
even though theoretically it should need onlyInt.MaxValue/16 * 8
so-Xmx2048m
topsIf I measure the resulting Array using SizeEstimator.scala it has
3758MB
which is27B
per element, which is aoffheap.Array
value class that should break down to 8 bytes long only but it obviously doesn't.It's probably my misuse of scala Value Classes, I think that if I do this
scala.Array[offheap.Array[Byte]](x,y,z)
then it doesn't matter thenoffheap.Array
is a value class and it breaks down to a normalx, y, z
instances on heap which I didn't expect to happen.And scala version from
scala-offheap
project