序列化对象大小与Java中的内存对象大小 [英] Serialized object size vs in memory object size in Java

查看:401
本文介绍了序列化对象大小与Java中的内存对象大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以根据Java中的序列化对象大小(大致)估算内存对象大小

Is there a way of estimating (roughly) in memory object size from Serialized object size in Java

推荐答案

内存大小通常为可序列化大小的一半至两倍.最极端的例子可能是大于80个字节的字节.序列化的内存中可以为16个字节.

The size in memory will be usually between half and double the serializable size. The most extreme example might be the Byte which is more than 80 bytes Serialized can be 16 bytes in memory.

您可以使用探查器来告诉您一个对象使用了多少内存.另一种方法是使用基于Instrumentation.getObjectSize(object)

You can use a profiler to tell you how much memory an object uses. Another way is to use a tool based on Instrumentation.getObjectSize(object)

您可能会发现有趣的获取对象

这篇关于序列化对象大小与Java中的内存对象大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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