Why is the JDK NIO using so many anon_inode file descriptors?

别来无恙 提交于 2019-12-04 09:39:38

It is indeed most probably epoll. Selectors use epoll by default starting with one of the early JDK 1.6.x releases and this selector impl uses more file descriptors than the old one in addition to the descriptors used by sockets themselves. You will also use more file descriptors if you register several Selectors with a single SocketChannel, for example separate selectors for reads and writes. If Netty uses NIO, it almost certainly makes use of selectors. In one app my file descriptors to sockets ratio was about 4 to 1 due to using epoll-based Selectors. It is possible to revert to the old selector implementation by changing the java.nio.channels.spi.SelectorProvider property and it will reduce the number of descriptors, but probably at the cost of performance (YMMV).

Perhaps these inodes are related to memory mapped "files" which would translate into Java's Direct ByteBuffers. The system call mmap(2) usually operates on files (using filehandles). But it also supports an option MAP_ANONYMOUS to manipulate the memory mapping without having an actual filehandle. This sounds like something which might need an "anonymous inode" internally.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!