gpt4 book ai didi

java - 虚拟机 : When does JVM need to copy memory content

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:06:34 25 4
gpt4 key购买 nike

我刚读了一个 wiki here ,其中一篇文章说:

Although theoretically these are general-purpose data structures, the implementation may select memory for alignment or paging characteristics, which are not otherwise accessible in Java. Typically, this would be used to allow the buffer contents to occupy the same physical memory used by the underlying operating system for its native I/O operations, thus allowing the most direct transfer mechanism, and eliminating the need for any additional copying

我对“eliminating the need for any additional copying”这句话很好奇,JVM 什么时候需要这个,为什么 NIO 可以避免它?

最佳答案

它说的是内核数据结构和用户空间数据结构之间的直接映射;通常在两者之间移动时需要上下文切换。但是,使用 nio 和直接缓冲区,不会发生上下文切换(和相应的内存副本)。

关于java - 虚拟机 : When does JVM need to copy memory content,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20697395/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com