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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:51:06+00:00 2026-05-24T09:51:06+00:00

I have written a C++ class for Windows and Linux that creates a memory-mapped

  • 0

I have written a C++ class for Windows and Linux that creates a memory-mapped view for an file of arbitrary size n. The code for the class constructor can be seen here. I am currently testing the code on Windows 32 bit XP.

I have found for file sizes 0 < n <= 1.7GB , the constructor returns a valid pointer to a memory-mapped view. However, for a file size >= 2 GB, MapViewOfFile returns a NULL value and an error code of 8, “Not enough storage is available to process this command”. Evidently, Windows cannot find an available address space of size 2 GB in the process.

Therefore, I may need to modify the class constructor to create a set of smaller memory-mapped views totaling >= 2GB bytes && < 2 ^ 32 – 1 bytes. The other requirement is to create a mapping between each of the smaller memory-mapped views and a randomly accessed address in the process’ address space.

Previously, I used the following code for random access:

char* KeyArray;

try {
    mmapFile = new cMemoryMappedFile(n);
}
catch (cException e)
{
    throw;
}

KeyArray = (char *)(mmapFile->GetPointer());
KeyArray[i] = ...

How should I modify the class to handle these requirements?

  • 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-24T09:51:07+00:00Added an answer on May 24, 2026 at 9:51 am

    I can’t see your pastebin link, but I can suggest a simple solution with a c++ class declaration. I think the implementation should be obvious from the comments:

    class ShiftingMemMap
    {
    public:
        // constructs a dynamically shifting memory map of a file...
        ShiftingMemMap ( const char* fileName, size_t view_size = 4096 );
    
        // retrieve/set a byte at the given file offset. If the offset is not currently in-view,
        // shift the view to encompass the offset. The reference should not be stored for later
        // access because the view may need to shift again...
        byte& operator [] ( unsigned int_64_t offset );
    
    private:
        int_64_t current_offset;
        size_t current_size;
    };
    

    All that being said, you could write a class that returns multiple views of a file to allow saving a reference for later and also editing different parts of the file simultaneously without having to shift the view back and forth repeatedly.

    class MemMap
    {
    public:
        MemMap ( const char* filename );
    
        shared_ptr<MemMapView> View ( unsigned int_64_t offset, size_t size = 4096 );
    };
    
    class MemMapView
    {
    public:
        char& operator[] ( size_t offset );
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written code within Python that doesn't release memory the way it should.
I have source code for a Windows DLL that is written in C++ and
I have a windows form app written in C#. the main_form class instantiates an
I have written a class in python that implements __str__(self) but when I use
I have written a class that will handle internal logging in my application. Now
I have written an apex class that will create a PDF quote and attach
In the library, right-click on a movieclip that you have written an ActionScript class
I have a class library that I have written in C#.net. I want to
I have a class library written in .Net that I would like to make
I have a Windows Mobile application written in Java that uses AWT for the

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.