“堆上”之间的差异和“堆外” [英] Difference between "on-heap" and "off-heap"

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

问题描述

Ehcache 讨论堆上和堆外内存。有什么不同?使用什么JVM args来配置它们?

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.

内部细节参与管理和使用堆外存储的问题在问题中发布的链接中并不十分明显,因此查看 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天全站免登陆