Using FileChannel Card Memory #

Is FileChannel#mapall memory needed for the resulting immediately allocated ByteBuffer, or is it allocated only on demand while reading from the buffer?

I just tried matching all 500+ MB files in a trivial test program and looked at the memory usage in this process. (Using both Runtime#totalMemoryand viewing it in the OS X activity monitor for the groovysh process.) Memory usage never transferred 30 MB of memory.

So, can a Java implementation β€œhide” some of the memory usage in its own calls? And if so, is there a way to find out what OS X is?

+3
source share
3 answers

Using memory is never easy. The actual buffer used FileChannel.mapis not part of the Java heap. Indeed, memory can be transferred to other processes. The file may not even be read from disk until the pages are affected.

+4
source

Yes. This is not part of the heap. However, depending on the OS, memory is still retained. On OS X, since it is UNIX-like, you should be able to use top or ps to check how much memory it needs.

+1
source

java.nio.MappedByteBuffer # load ( ):

, , ,      * .      * -      *.

+1
source

Source: https://habr.com/ru/post/1707936/


All Articles