Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> when you do use Java NIO MappedByteBuffer, we still have to copy to a temporary byte[] in order to do any real processing

Does anyone know why this is the case?



Well, with a MappedByteBuffer (or any DirectByteBuffer), if you want to manipulate the data as a Java type (e.g. byte[]) you have to copy the data into the heap. byte[] cannot exist outside of the heap.

Still, I wonder why they're using a MappedByteBuffer in the first place if they're working with the data in the Java heap.


mmap uses the virtual memory manager to map a file into virtual memory as it does for swapping.

The memory you have is therefore allocated by the kernel of your operating system and oblivious to any garbage collector you might have.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: