简体   繁体   English

Java Ram使用不一致

[英]Java Ram Usage Inconsistencies

I am currently working on a 2D java game which utilizes a linkedhashmap for rendering data at a particular tile. 我目前正在开发一个2D Java游戏,该游戏利用LinkedHashMap在特定图块上渲染数据。 When I serialize the class object which contains this as well as a few other non transient objects used for map rendering the file which is output only has a size of 4kb. 当我序列化包含此对象的类对象以及用于地图渲染的一些其他非临时对象时,输出的文件仅具有4kb的大小。 To my understanding RAM usage depends upon the size of whatever is being read from, but apparently I am using up a max of 20% of my memory reading from a file that is less than 4kb in size. 据我了解,RAM的使用取决于要读取的内容的大小,但是显然我正在使用最大小于20 kb的文件读取的内存的20%。 This leads me to believe that my understanding of how RAM works is wrong or I am missing something that is giving me bad RAM readings. 这使我相信我对RAM的工作方式的理解是错误的,或者我错过了一些使我的RAM读数不好的东西。

Method of RAM Analysis RAM分析方法

usedPercent = (double) (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / Runtime.getRuntime().maxMemory();

The piece you are missing is that the Java Runtime Environment grabs memory to manage for itself, this includes class-path loading, intern caches, process space, stack and heap and permgen space. 您缺少的部分是Java Runtime Environment会自动获取内存进行管理,其中包括类路径加载,内部高速缓存,进程空间,堆栈和堆以及permgen空间。

Basically, as a Java developer you aren't responsible for memory management and Java does not provide tools to enable you to perform memory management. 基本上,作为Java开发人员,您不负责内存管理,并且Java不提供使您能够执行内存管理的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM