“堆上"和“堆上"的区别和“堆外" [英] Difference between "on-heap" and "off-heap"

查看:26
本文介绍了“堆上"和“堆上"的区别和“堆外"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ehcache 讨论堆内和堆外内存.有什么区别?使用哪些 JVM 参数来配置它们?

Ehcache talks about on-heap and off-heap memory. What is the difference? What JVM args are used to configure them?

推荐答案

堆上存储是指将出现在 Java 堆中(也受 GC)的对象.另一方面,堆外存储是指由 EHCache 管理的(序列化的)对象,但存储在堆外(也不受 GC).由于堆外存储继续在内存中管理,它比堆上存储略慢,但仍然比磁盘存储快.

The on-heap store refers to objects that will be present in the Java heap (and also subject to GC). On the other hand, the off-heap store refers to (serialized) objects that are managed by EHCache, but stored outside the heap (and also not subject to GC). As the off-heap store continues to be managed in memory, it is slightly slower than the on-heap store, but still faster than the disk store.

关于off-heap store的管理和使用的内部细节在问题贴出的链接中不是很明显,所以最好查看Terracotta BigMemory,用于管理磁盘外存储.BigMemory(堆外存储)用于避免几兆字节或千兆字节大的堆上的 GC 开销.BigMemory使用JVM进程的内存地址空间,通过直接与其他原生 Java 对象不同,不受 GC 影响的 ByteBuffers.

The internal details involved in management and usage of the off-heap store aren't very evident in the link posted in the question, so it would be wise to check out the details of Terracotta BigMemory, which is used to manage the off-disk store. BigMemory (the off-heap store) is to be used to avoid the overhead of GC on a heap that is several Megabytes or Gigabytes large. BigMemory uses the memory address space of the JVM process, via direct ByteBuffers that are not subject to GC unlike other native Java objects.

这篇关于“堆上"和“堆上"的区别和“堆外"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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