Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:10:16+00:00 2026-06-16T00:10:16+00:00

Reading a file in using a Mapped FileChannel seems to be lightning fast… But

  • 0

Reading a file in using a Mapped FileChannel seems to be lightning fast… But I was wondering how they are doing this?

Are they simply just reading in a large (~64kB) buffer and then letting me march through that? Or is there more to it?

I’m just impressed by the speed and want to better understand the algorithm behind it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:10:16+00:00Added an answer on June 16, 2026 at 12:10 am

    memory mapping, maps the file into your memory and Java provides a library to to wrap this so you can access it relatively safely.

    It’s benefits include:

    • there only one copy in memory, in the OS disk cache and in your application(s) memory.
    • you can access random areas of the file without a system call.
    • Java does limit how much you can map in. i.e. if your maximum heap is 1 GB and your maximum direct memory is 1 GB, you can still map in 1 TB.

    It’s disadvantages include:

    • it consumes virtual memory which it doesn’t give back if you re-map or close the files. This is not such a problem if you have a 64-bit JVM, but is very limiting if you have a 32-bit JVM which might only have 1 GB free. It releases virtual memory when the GC runs.
    • it reads/writes a minimum of a page at a time. This can be good if you have lots of random access but actually slows sequential access if you are reading from/writing to many files on disk. Appending to many files randomly 4KB at a time can result in highly fragments files which is not idea.
    • working with memory mapped files can be more difficult that using a plain DataXxxxStream or BufferedReader/Writer.

    I have written a couple of libraries making memory mapped files easier to work with and I would say I would use it when ultra-low latency is critical or you need to read large amounts of memory which you expect to be in disk cache already and you want to make the most of your disk cache.

    It’s worth noting that memory mapped doesn’t make your disk sub-system faster and if that is your limiting factor it won’t matter which way you read/write data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am reading an excel file using this code i found over the net:
I am reading a file using File.ReadAllText(filename.txt). This file is located in very same
I am reading a file using perl script. This file consists of strings with
I am reading excel file using jxl library.But I am facing a problem when
I am reading a file using JS like this: var fso = new ActiveXObject(Scripting.FileSystemObject);
I have a mapped Webdav Drive and i can't open file for reading using
I'm reading file using java. File contains € chars but java interpret it like
I have xml file with TAG like this: <Question>dzia&amp;#322;owa</Question> I'm reading this file using
I'm reading a file using bufferedreader, so lets say i have line = br.readLine();
I am reading one file using ruby in which I have written regexp in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.