1

I am curious whether the mappedbytebuffer occupies direct memory in Java? As mentiond in here

A direct byte buffer may also be created by mapping a region of a file directly into memory

When I map a file into memory, the direct memory should be used. But I started a program with JVM param "-XX:MaxDirectMemorySize=200MB" then I tried to map a file of 1GB into memory, it worked. What's more, I allocated a directByteBuffer with 200MB first and then tried to map the file of 1GB into memory, and it still worked! So, which part of the memory does mappedbytebuffer occupy?

Jenson
  • 87
  • 5
  • What do you think the word "may" in that quote means? Your question is "Does it"? The word "may" is the answer: Perhaps! Maybe! Could be! Unknown! Depends! --- Any other words that would help you understand it? – Andreas Jun 22 '17 at 03:28
  • What is the point in using a MMF bigger than your heap? that defeats the purpose of wiring the file into memory. – bichito Jun 23 '17 at 03:15

1 Answers1

1

i think,when you map a bigger file into small memory, the instance of mappedbytebuffer may mapping a region of a file which you have just used into memory ,then the other region which have been map in memory will exchange into SWAP(the virtual memory on hard disk ) by MMU

Panciz
  • 2,183
  • 2
  • 30
  • 54