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

标签 java nio

我刚读了一个 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/

相关文章:

java - Maven、CDI、JUnit、JPA。想要针对 HSQLDB 运行测试

SocketChannel.write() 的 Java NIO 线程问题

java nio 从文件中读取行

java - 使用 '|' 拆分字符串

java - SQlite 数据库不将 double 值存储为字符串

java: 类成员的内存是如何分配的?

java - Struts2 Tiles - 如何实现?

java - NIO 客户端/服务器安全地验证凭据

java - 将 NIO 与 IO 混合

java - 将文件写入 ServletOutputStream 的最有效方法