是否有可能在Java中有多个堆? [英] Is it possible to have multiple heaps in java?

查看:145
本文介绍了是否有可能在Java中有多个堆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在java中有多个堆?如果有可能,那么在哪种情况下它确实发生?

解决方案

已经有多个内存区域,但只有一个Java堆这样。

通常有;


  • 可能被分解为


    • 的Java堆Eden空间,

    • 存活空间

    • 占有空间


    • 用于小型直接内存分配的本机内存堆。例如 ByteBuffer.allocateDirect(4)参见在/ proc / pid / maps中丢失[heap]部分以获得对本地空间中 [heap] 区域的有趣讨论。
    • b $ b
    • 大型直接分配的匿名内存映射。 ByteBuffer.allocateDirect(10000000)

    • 线程的堆栈空间。即方法中的局部变量。

    • 代码的Perm Gen或MetaSpace。是字节码还是JIT编译代码

    • 本地代码的共享库。这包括DLL / SO以及为什么hello world似乎使用这么多内存。
    • 内存映射文件区域。例如FileChannel.map(..)

    • 其他地区很少直接使用,如VDSO。只能通过JNI或不安全的方式访问。



    当你说堆时,它指的是第一个, Java对象和垃圾收集器管理。实际上,也有本地的堆,但这是不可互换的,并且具有非常不同的目的,事实上大多数Java开发人员不需要知道它存在。



    注意:这就是JVM在Windows和Linux上的实现方式,标准中没有任何内容表明这些必须存在以供Java使用。


    Is it possible to have multiple heaps in java? If it is possible then in which cases it does happen?

    解决方案

    There is already multiple memory regions, but only one Java heap as such.

    Typically there are;

    • Java heap which might be broken into
      • Eden space,
      • Survivor Spaces,
      • Tenures space.
    • The native memory heap for small direct memory allocation. e.g. ByteBuffer.allocateDirect(4) See missing [heap] section in /proc/pid/maps for an interesting discussion of the [heap] region in native space.
    • Anonymous memory mapping for large direct allocations. ByteBuffer.allocateDirect(10000000)
    • Stack space for the threads. i.e. the local variables in a method.
    • Perm Gen or MetaSpace for the code. WHere you byte code and the JIT compiled code goes
    • Shared libraries for native code. This includes DLL/SO and why "hello world" appears to use so much memory.
    • Memory mapped file regions. e.g. FileChannel.map(..)
    • Other regions rarely used directly such as the VDSO. Only accessible via JNI or Unsafe.

    When you say "the heap" this refers to the first one, the one you can naturally allocate Java object on and the Garbage Collector manages. In reality, there is also the native "heap" but this is not interchangeable and has a very different purpose, in fact most Java developers would never need to know it exists.

    Note: this is how the JVM is implemented on Windows and Linux, there is nothing in the standard which says these have to exists for Java to work.

    这篇关于是否有可能在Java中有多个堆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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