Scala集合内存占用特征 [英] Scala collection memory footprint characteristics

查看:56
本文介绍了Scala集合内存占用特征的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个关于 性能特征的方便页面类.是否有类似的内存占用数据?

There is a handy page about performance characteristics of the Scala collection classes. Is there similar data on memory footprint?

我有一种情况,我担心内存使用,并希望在我选择要使用的集合时考虑到这一点.例如,在 Array[Array[T]]Vector[Vector[T]] 之间.

I have a situation where I'm concerned about memory use and would like to factor this in my choice of collection to use. For instance, between Array[Array[T]] and Vector[Vector[T]].

推荐答案

这是我在 2.9.0 上用 1,000,000 个对象填充这些各自的不可变序列后发现的结果.我让它们都指向同一个对象,以计算出内容的大小.

Here is what I've found out by filling up those respective immutable sequences with 1,000,000 objects on 2.9.0. I had them all point to the same object to factor out the size of the content.

  • Array:1x (32 位基线 4,000,016 字节;64 位基线 8,000,024)
  • 矢量:1.17x
  • ListQueueStack:4x
  • 评估 Stream:10x
  • Array: 1x (baseline 4,000,016 bytes on 32 bits; 8,000,024 on 64 bits)
  • Vector: 1.17x
  • List, Queue, Stack: 4x
  • evaluated Stream: 10x

System.gc 被调用,然后触发堆转储,然后在 Eclipse MAT 中打开.

System.gc was called then triggered heap dump then opened in Eclipse MAT.

基于那个 ArrayVector 是非常封闭的.

Based on that Array and Vector are pretty closed.

这篇关于Scala集合内存占用特征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆