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

  • SEARCH
  • Home
  • 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 8597809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:59:56+00:00 2026-06-12T00:59:56+00:00

I am trying to understand what would be the difference between calling FileChannel.write in

  • 0

I am trying to understand what would be the difference between calling FileChannel.write in short successions with a 16k buffer AND mapping multiple ByteBuffers with an append size of 16k as described here: https://stackoverflow.com/a/7367952/962872

I would think that the mapped bytebuffer approach produces a lot of garbage as you discard the MappedByteBuffers after each append. And I am not sure it is faster either. And you still have to do a bunch of mapping operations… (one per append).

Or perhaps you should map a huge ByteBuffer (as big as possible) and just keep writing to this MappedByteBuffer?

I am using the FileChannel.write approach with a Java-side 16kb buffer as a “fast” way to write a file but I want to make sure I am not missing something faster/better.

Can anyone shed a light?

  • 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-12T00:59:57+00:00Added an answer on June 12, 2026 at 12:59 am

    I would think that the mapped bytebuffer approach produces a lot of garbage as you discard the MappedByteBuffers after each append.

    It would if you created 16 KB buffers. If you created 1 GB buffers would won’t need as many and there is little penalty for doing so (assuming you have a 64-bit JVM)

    I am using the FileChannel.write approach with a Java-side 16kb buffer as a “fast” way to write a file but I want to make sure I am not missing something faster/better.

    I would check you are not already writing as fast or faster than you drive can write anyway. The main advantage Memory Mapped Files give you is much lower typical latency. The throughput you can write will be limited by the speed of your drive. If you have a typical SSD, your CPU can still write out data faster than it can consume and if you use HDD it probably doesn’t matter what you do as the drive is so much slower.

    Typical write throughput of

    • a modern CPU: 2,000 – 6,000 MB/sec
    • an SSD: 300 – 1,200 MB/sec
    • a disk controller: 200 – 600 MB/sec
    • an HDD: 20 -60 MB/sec.

    Often when CPU is not the bottleneck, what you do in software has little impact on the performance of the application.

    In terms of latency, the typical latency of

    • FileChannel.write() : 10 – 40 micro-seconds but can spike to over one millisecond.
    • Writing to memory mapped file : 100 nano-second for a short message but can spike to 100 mi-seconds when a new memory mapping is required.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just had a noob question. I'm trying to understand the difference between calling self
I am trying to understand the difference between phones, and the software on them.
I'm trying to understand the difference between regular Memcache and Doctrine's MemcacheCache. In my
I'm trying to understand the difference between working with just long, long2, long3, long4,
I'm trying to understand the difference between Ruby threads pre-1.9 and 1.9 (in the
I am trying to understand the difference between matches() and find() . According to
I am trying to understand the difference between shallow copy and deep copy in
I am trying to understand difference between IQueryable, ICollection, IList & IDictionary interface which
I am trying to understand the difference between shallow copy and deep copy in
I am trying to understand difference between IQueryable, ICollection, IList & IDictionary interface which

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.