memory-mapped-files

Memory Mapped Files .NET

I have a project and it needs to access a large amount of proprietary data in ASP.NET. This was done on the Linux/PHP by loading the data in shared memory. I was wondering if trying to use Memory Mapped Files would be the way to go, or if there is a better way with better .NET support. I was thinking of using the Data Cache but not su...

mmaping two consecutive pages

I'm writing a unit test for my UTF8 manipulation library, and I want my test to segfault if a function goes into a buffer overflow. So I came up with the idea to mmap two pages next to each other in memory, the first with PROT_READ | PROT_WRITE, and the second with PROT_NONE. That way, if any overflow occurs, a segfault is guaranteed. ...

Memory mapping of files vs CreateFile/ReadFile.

What are the drawbacks (if any) of using memory mapped file to read (regular sized files) over doing the same using CreateFile ReadFile combination? ...

What is the best way to display large files without using large amounts of memory?

Many hex editors, such as Hex Workshop, can even read large-sized files while keeping a relatively small memory footprint, but still manage to keep scrolling smooth. I'm looking for the best way to achieve this, and so I have several related questions. Should I just use FileStream?   - Is its buffering based on the current Seek location?...

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? ...

windows CreateFilemapping

link textIn my project I have implemented the CreateFileMapping concept to share memory between two processes. I have a server process in which I store the memory address of my session data, which contains details about a particular image. And I have a client process in which I read that address from the buffer. Now the problem is the ad...

what is the suggested number of bytes each time for files too large to be memory mapped at one time?

I am opening files using memory map. The files are apparently too big (6GB on a 32-bit PC) to be mapped in one ago. So I am thinking of mapping part of it each time and adjusting the offsets in the next mapping. Is there an optimal number of bytes for each mapping or is there a way to determine such a figure? Thanks. ...

Can I get a path for a Memory Mapped File? (.NET 4.0)

I want that a non-.NET application access a Memory Mapped file, but this application is not aware of the existence of Memory Mapped files, so I need the file path. It is possible? ...

Memory allocators

I want to make a virtual allocator using c++ on windows,, which allocate data on a file on the hard disk, to reduce physical memory usage when allocate large objects !.. I don't want to use system virtual memory with virtualAlloc.. . I want to create a file on the disk and use it to allocate the whole objects and then move the part or th...

What is the most appropriate way to use .Net 4.0's MemoryMappedViewAccessors?

When displaying a large, memory mapped file in a scrollable box, is it more appropriate to have the view represent the whole file, or only the region of the file currently being displayed? More broadly, at what level of the abstraction is paging done with .Net's memory mapped files? Is the page size/amount of the file held in memory rel...

Returning a memory mapped InputStream from a content provider?

The the client side of a content provider consumer I can do something like this, to get a proper InputStream for reading the picture: InputStream is = getContentResolver().openInputStream(pictureUri); It is a nice API, and will on the server side, the actual content provider result in a call to: public ParcelFileDescriptor openFile(U...

Monitoring Windows Memory Mapped Files

In Windows, how can I keep track of the file mapping objects created by CreateFileMapping()? Basically I want to know how many memory mapped files are in use and the information like their names, sizes, etc. Thanks! ...

MemoryMappedFile.CreateFromFile always throws UnauthorizedAccessException

I realize .NET 4.0 is in Beta, but I'm hoping someone has a resolution for this. I'm trying to create a memory mapped file from a DLL: FileStream file = File.OpenRead("C:\mydll.dll"); using (MemoryMappedFile mappedFile = MemoryMappedFile.CreateFromFile(file, "PEIMAGE", 1024 * 1024, MemoryMappedFileAccess.ReadExecute)) { using (M...

memory mapped files reamain in physical memory

I have a process that uses a lot of memory mapped files. Problem is that those files are kept in physical memory, even when the machine is low on memory, and other processes require this memory. I've tried using SetProcessWorkingSetSize to limit the process working set, but it doesn't help, the process' working set keeps growing over th...

Memory mapping physical disks and volumes

In Windows it's possible to open devices and volumes via CreateFile(). I've used this successfully before to ReadFile() from devices, but now I want to switch to memory-mapping. In the following code, I receive INVALID_HANDLE_VALUE for the value of b, and c is set to 87, ERROR_INVALID_PARAMETER. HANDLE a = ::CreateFileA("\\\\.\\h:", GEN...

Memory mapped files optional write possible?

When using memory-mapped files it seems it is either read-only, or write-only. By this I mean you can't: have one open for writing, and later decide not to save it have open open for reading, and later decide to save it Our application uses a writeable memory-mapped file to save data files, but since the user might want to exit ...

.Net 4.0 Memory-Mapped Files verses RDMS Storage

I'm interested in people's thoughts comparing storing data in a traditional SQL based Database or utilising a Memory-Mapped File such as the one in the new .Net 4.0 runtime. The data in question would be arrays of simple structures. Obvious pros and cons: SQL Database Pros Adhoc query support SQL Management Tools Schema changes (add...

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 memory-mapped files or not - first for writing the single chunks to disk, second for the singl...

In-memory version of Java's FileChannel

I'm in the process of making some changes to a library that I'm using. In order to reduce memory usage the library is writing its temporary data to disk instead of keeping it in memory. However, for my usage scenario it is more efficient to keep it in memory. It also has some concurrency issues, because it has constant names for its temp...

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 to add: In other words, I'm looking for something that would behave like (the now obsolet...