Questions tagged [memory-mapped-files]

A file whose contents are mapped in virtual memory.

The wiki page describes a memory memory map as :

A memory-mapped file is a segment of virtual memory which has been assigned a direct byte-for-byte correlation with some portion of a file or file-like resource. This resource is typically a file that is physically present on-disk, but can also be a device, shared memory object, or other resource that the operating system can reference through a file descriptor. Once present, this correlation between the file and the memory space permits applications to treat the mapped portion as if it were primary memory.

848 questions
56
votes
13 answers

How to unmap a file from memory mapped using FileChannel in java?

I am mapping a file("sample.txt") to memory using FileChannel.map() and then closing the channel using fc.close(). After this when I write to the file using FileOutputStream, I am getting the following error: java.io.FileNotFoundException: …
learner135
  • 573
  • 1
  • 4
  • 6
45
votes
3 answers

When to use memory-mapped files?

I have an application that receives chunks of data over the network, and writes these to disk. Once all chunks have been received, they can be decoded/recombined into the single file they actually represent. I'm wondering if it's useful to use…
Pygmy
  • 675
  • 2
  • 10
  • 13
39
votes
6 answers

Memory-mapped files and low-memory scenarios

How does the iOS platform handle memory-mapped files during low-memory scenarios? By low-memory scenarios, I mean when the OS sends the UIApplicationDidReceiveMemoryWarningNotification notification to all observers in the application. Our files are…
Aidan Steele
  • 10,999
  • 6
  • 38
  • 59
30
votes
5 answers

How to dynamically expand a Memory Mapped File

I've used C# to solve the following requirement.. - create an app the can receive a lot of data fast - you must be able to analyse the received data while more are incoming. - use as little CPU and disk as possible My idea for an algorithm…
Moberg
  • 783
  • 1
  • 8
  • 17
29
votes
6 answers

How big can a memory-mapped file be?

What limits the size of a memory-mapped file? I know it can't be bigger than the largest continuous chunk of unallocated address space, and that there should be enough free disk space. But are there other limits?
user88185
  • 293
  • 1
  • 3
  • 4
28
votes
3 answers

Posix shared memory vs mapped files

Having learnt a bit about the subject, can anyone tell, what is the real difference between POSIX shared memory (shm_open) and POSIX mapped files (mmap)? Both seems to use the /dev/tmpfs subsystem, rather then older IPC mechanism. So is there any…
SyBer
  • 5,407
  • 13
  • 55
  • 64
27
votes
1 answer

Memory barriers and the TLB

Memory barriers guarantee that the data cache will be consistent. However, does it guarantee that the TLB will be consistent? I am seeing a problem where the JVM (java 7 update 1) sometimes crashes with memory errors (SIGBUS, SIGSEG) when passing a…
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
26
votes
7 answers

Can multiple threads see writes on a direct mapped ByteBuffer in Java?

I'm working on something that uses ByteBuffers built from memory-mapped files (via FileChannel.map()) as well as in-memory direct ByteBuffers. I am trying to understand the concurrency and memory model constraints. I have read all of the relevant…
Alex Miller
  • 69,183
  • 25
  • 122
  • 167
24
votes
3 answers

How to allocate and free aligned memory in C

How do you allocate memory that's aligned to a specific boundary in C (e.g., cache line boundary)? I'm looking for malloc/free like implementation that ideally would be as portable as possible --- at least between 32 and 64 bit architectures. Edit…
fuad
  • 4,265
  • 9
  • 34
  • 32
22
votes
5 answers

How can I quickly read bytes from a memory mapped file in .NET?

In some situations the MemoryMappedViewAccessor class just doesn't cut it for reading bytes efficiently; the best we get is the generic ReadArray which it the route for all structs and involves several unnecessary steps when you just need…
Kieren Johnstone
  • 41,277
  • 16
  • 94
  • 144
21
votes
2 answers

Memory-Mapped MappedByteBuffer or Direct ByteBuffer for DB Implementation?

This looks like a long question because of all the context. There are 2 questions inside the novel below. Thank you for taking the time to read this and provide assistance. Situation I am working on a scalable datastore implementation that can…
Riyad Kalla
  • 10,604
  • 7
  • 53
  • 56
20
votes
9 answers

Java: Memory efficient ByteArrayOutputStream

I've got a 40MB file in the disk and I need to "map" it into memory using a byte array. At first, I thought writing the file to a ByteArrayOutputStream would be the best way, but I find it takes about 160MB of heap space at some moment during the…
user683887
  • 1,260
  • 1
  • 10
  • 20
20
votes
3 answers

Is it possible to np.concatenate memory-mapped files?

I saved a couple of numpy arrays with np.save(), and put together they're quite huge. Is it possible to load them all as memory-mapped files, and then concatenate and slice through all of them without ever loading anythin into memory?
vedran
  • 751
  • 1
  • 5
  • 16
19
votes
3 answers

.NET 4.0 Memory Mapped Files Performance

I'd like to know if anyone tried new .NET 4.0 Memory Mapped Files features? I know that they are as old as OS but native handling in .NET is new. Has anyone been able to test this and say something about performance? I'm quite interested in access…
michajas
  • 347
  • 1
  • 5
  • 16
18
votes
6 answers

System Error 0x5: CreateFileMapping()

I wish to implement IPC using Named Shared Memory. To do this, one of the steps is getting a handle to a Mapping Memory Object, using CreateFileMapping(). I do it exactly as MSDN website reccommends:…
Bunkai.Satori
  • 4,698
  • 13
  • 49
  • 77
1
2 3
56 57