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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:19:52+00:00 2026-06-18T20:19:52+00:00

Currently I am debugging a program in linux that looks like this: int main(){

  • 0

Currently I am debugging a program in linux that looks like this:

int main(){
    loadHugeFile();
    processTheDataOfTheFile();
    return 0;
}

The thing is loadHugeFile function needs to load a very huge file in gigabytes that takes about 5 minutes, while processTheDataOfTheFile takes less than 10 seconds to calculate the required data and return some values. In the future, the file’s size might increase even further, and it will take even more time to load. The file is an invert index, so the whole file is needed.

Is it possible to have one process load this file into the RAM, retain it and have any other process access this part of the loaded file? This is to skip that many minutes loading. I recall Windows has this function that allows you to access/modify another process’s memory, but what are my available choices here in linux?

  • 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-18T20:19:53+00:00Added an answer on June 18, 2026 at 8:19 pm

    You can use mmap function.

    In computing, mmap(2) is a POSIX-compliant Unix system call that maps files or devices into memory. It is a method of memory-mapped file I/O.

    You got 2 advantages. Extreme speed in loading file and the content will be in a memory area that can be shared between many other processes (just use mmap with the flag MAP_SHARED).

    You can test the speed of mmap with this short and dirty code. Just compile it and exec it passing the file you want to load as paramenter.

    #include <stdio.h>
    #include <stdint.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <sys/mman.h>
    
    int main(int argc, char *argv[])
    {
        struct stat sb;
    
        int fd = open(argv[1], O_RDONLY);
    
        // get the size in bytes of the file
        fstat (fd, &sb);
    
        // map the file in a memory area
        char *p = mmap (0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
    
        // print 3 char of the file to demostrate it is loaded ;)
        printf("first 3 chars of the file: %c %c %c\n", p[0], p[1], p[2]);
    
        close(fd);
    
        // detach
        munmap(p, sb.st_size);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently debugging an Ms SQL Function (SQL 2008). In this function, I have
Hello everyone and thanks for your help! I currently have this program that renames
When I start debugging the project we are currently working on, the program window
I'm currently debugging an ASP.NET MVC application that was just deployed to a different
I am currently debugging a sizable program. When I come to the following line
I'm making a program (think: something like Launchy ) that, more or less, goes
I am currently working on a program in C# that allows our users to
I have a program that sends MSMQ messages to a remote machine. This works
I am debugging my program with FastMM and it seems that a lot of
i'm working with a multi-threaded program (using pthreads) that currently create a background thread

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.