here is a test for FileChannel.write() , and mmap file write
https://github.com/jkreps/valencia/blob/master/src/test/java/valencia/TestLinearWritePerformance.java
what,s more , MaxDirectMemorySize dont work for memory hold by mmap file .
MaxDirectMemorySize dont work for memory hold by mmap file .SHR memory is equals the mmap file size .


@Ah39 Compared with FileChannel, MMAP can write to the page cache directly, but FileChannel with directbuffer needs to write to memory first, then write to the page cache. so MMAP has an advantage when writing a lot of small data into a file.
@duhengforever but the rocketmq may hold 100G even more SHR memory .
how to control the memory use by rocketmq ,by mmap file ??

@duhengforever but the rocketmq may hold 100G even more SHR memory .
how to control the memory use by rocketmq ,by mmap file ??
Maybe using the dio in the future will be a good choice, memory management is entirely done by the application layer. However, This is a major change, and if you have any ideas, feel free to discuss them in the [email protected] mailing list.
Most helpful comment
@Ah39 Compared with FileChannel, MMAP can write to the page cache directly, but FileChannel with directbuffer needs to write to memory first, then write to the page cache. so MMAP has an advantage when writing a lot of small data into a file.