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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:04:06+00:00 2026-06-03T22:04:06+00:00

My understanding of how memory mapped files work in C# is that every request

  • 0

My understanding of how memory mapped files work in C# is that every request for data results in a copy. For instance, if you had a large data structure persisted as a file, using a memory mapped file would result in memory for the actual file mapped into RAM, and a copy residing in a GC heap once it was read from the file.

I’m assuming this is because pointers and the GC don’t get along well together generally speaking.

So, is there any way around this?

  • Perhaps via some mixed mode C++ that can expose a managed API over the memory mapped data?
  • What about direct pointer manipulation with unsafe C#?

The general problem I’m trying to solve is sharing a large data structure between multiple processes. The data structure is used to answer a small set of “questions” that can be exposed as a simple API (i.e. basically, a highly specialized index of a bunch of other data).

On a side note, doesn’t this make the .NET API useless for the “sharing large amounts of data” scenario?

  • 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-03T22:04:07+00:00Added an answer on June 3, 2026 at 10:04 pm

    You can use unsafe code to directly access the mapped memory. I suggest you look into “blittable structs” which are struct types which can be copied around in memory without modification. Here is an example:

    struct MyDataRecord { public int X, Y; }
    
    ...
    
    for (var i = 0 .. 10) {
     ((MyDataRecord*)pointerToUnmanagedMemory)[i] = new MyDataRecord() { X = i, Y = i * i };
    }
    

    This is very performant and kind of convenient.

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

Sidebar

Related Questions

It is my understanding that, in addition to allocating memory, alloc sets all instance
My understanding of finalization is this: To clean up or reclaim the memory that
My understanding is that shadow page tables eliminate the need to emulate physical memory
Memory management with delegates, it is my understanding that I don't retain delegates, I
Ok so from my understanding each application normally gets 16 mb memory to work
I'm certain that I'm missing some fundamental understanding of iOS memory management and, despite
How do programs that edit memory of other processes work, such as Cheat Engine
My understanding is that in unix, when memory is freed, the memory doesn't get
My understanding of expression trees is : Expression trees are in-memory representation of expression-like
I am not understanding the 'aligning allocated memory' part from the mprotect usage. I

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.