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 6869235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:31:58+00:00 2026-05-27T03:31:58+00:00

I am running some large array processing code (on a Pentium running Linux). The

  • 0

I am running some large array processing code (on a Pentium running Linux). The sizes of the arrays are large enough for the processes to swap. So far it is working, probably because i try to keep my read and writes contiguous. However, I will soon need to handle larger arrays. In this scenario, would switching over to anonymous mmapped blocks help ?

If so would you please explain why.

In my shallow understanding, mmap implements a memory mapped file mounted from a tmpfs partition which under memory pressure would fall back to the swapping mechanism. What I would like to understand is how does mmap do it better than the standard malloc (for the sake or argument I am assuming that it is indeed better, I do not know if it is so).

Note: Please do not suggest getting a 64 bit and more RAM. That, unfortunately, is not an option.

  • 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-05-27T03:31:59+00:00Added an answer on May 27, 2026 at 3:31 am

    The memory that backs your malloc() allocations is handled by the kernel in much the same way as the memory that backs private anonymous mappings created with mmap(). In fact, for large allocations malloc() will create an anonymous mapping with mmap() to back it anyway, so you are unlikely to see much difference by explicitly using mmap() yourself.

    At the end of the day, if your working set exceeds the physical memory size then you will need to use swap, and whether you use anonymous mappings created with mmap() or malloc() is not going to change that. The best thing you can do is to try and refactor your algorithm so that it has good locality of reference, which will reduce the extent to which swap hurts you.

    You can also try to give the kernel some hints about your usage of the memory with the madvise() system call.

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

Sidebar

Related Questions

I have an automated test running on my program that generates some large MPG
I was running some dynamic programming code (trying to brute-force disprove the Collatz conjecture
I'm running some code through FxCop and am currently looking at clearing all of
I'm writing some pretty CPU-intensive, concurrent numerical code that will process large amounts of
I am running some large regression models in R in a grid computing environment.
We're running a moderate size (350GB) database with some fairly large tables (a few
I'm running a 4-node Cassandra cluster. Some of our nodes have some very large
I have quite a large project to accomplish and I'm running into some dead
After running some usability tests, I found that participants opened a jQuery Lightbox to
I'm running some JUnit tests on my applications. Every test has a for loop

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.