Scala集合内存占用特征

编程入门 行业动态 更新时间:2024-10-27 10:21:23
本文介绍了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
  • List、Queue、Stack: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.

基于那个 Array 和 Vector 是非常封闭的.

Based on that Array and Vector are pretty closed.

更多推荐

Scala集合内存占用特征

本文发布于:2023-05-27 01:50:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/275017.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:特征   内存   Scala

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!