problem about memory-mapped-files-Collection of common programming errors


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

  • Andrew Harry
    c#-4.0 memory-mapped-files rdms
    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 ProsAdhoc query support SQL Management Tools Schema changes (adding more columns and setting default values)Memory-Mapped ProsLighter overhead? (this is an assumption on my part) Shareable between process threads Any others?Is it wo

  • OopsUser
    c++ file boost memory-mapped-files
    Important edit : The problem is not what i stated, after manually profiling i understood that when i replace the line : “file >> x >> y >> z;” with the line “file.readline(buffer, size);”it takes only 0.4 seconds, so the question is entirely different, how to parse the floats from the line, file>>x>>y>>z;(i don’t know if i should delete the question or not, because the original question is not relevant)=== OLD === After vast research on the internet and stack overflow, i understood that the best

  • Rob Kielty
    java centos memory-mapped-files tlb memory-barriers
    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 MappedByteBuffer between threads.e.g.final AtomicReference<MappedByteBuffer> mbbQueue = new AtomicReference<>();// in a background thread. MappedByteBuffer map = raf.map(MapMode.READ_WRITE, offset, allocationSize); Thread.yield(); while (!i

  • Cratylus
    java tcp io nio memory-mapped-files
    I am interested in implemented the following simple flow: Client sends to a server process a simple message which the server stores. Since the message does not have any hierarchical structure IMO the best approach is to save it in a file instead of an rdb. But I want to figure out how to optimize this since as I see it there are 2 choices: Server sends a 200 OK to the client and then stores the message so the client does not notice any delay Server saves the message and then sends the 200OK but

  • Aan
    c++ winapi memory-leaks memory-mapped-files memory-mapping
    I am trying to use memory-mapped files as:hFile = ::CreateFile(State.Path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,0, OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN, 0);//open the fileif(hFile !=INVALID_HANDLE_VALUE){ hMap= ::CreateFileMapping(hFile, 0, PAGE_READONLY | SEC_COMMIT, 0, 0, 0);//create Mem mapping for the file in virtual memory if( hMap!=NULL){ base = ::MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);//load the mapped file into the RAM //start to compare some bytes (values) from mspai

  • Vladimir Gritsenko
    ios nsdata memory-mapped-files
    I have a file which I memory-map with NSData. I then delete this file via an NSFileManager without any error, and proceed to check that the file is indeed not there (as far as NSFileManager and ls are concerned). However, I can still read data from the bytes pointer I got from NSData previously!In the simulator, I sometimes get seemingly unrelated crashes. On the device, everything seems to work fine. I’m very curious to know what’s going on, and what should I expect (what I expected in the past

  • Johannes Schaub – litb
    c++ c qt mmap memory-mapped-files
    I am using Qt to map a file to a piece of memory pagesQFile::map (qint64 offset, qint64 size, MemoryMapFlags flags = NoOptions)Essentially, this should be a mmap system function call. I wonder how I can guarantee that I can access the returned memory, even if the file on disk is truncated. I seem to need this because I read from a disk file and want to gracefully handle errorsif (offset > m_file.size()) // throw an error… if (m_mappedFile != NULL) return m_mappedFile + offset;Obviously, thi

  • Mario
    c# mutex memory-mapped-files
    I’m constantly reading from a memory mapped file another process is writing to and use a mutex to synchronize this operation. In my few tests so far this works just fine, but… what if my application crashes right after acquiring the mutex and before releasing it? Is there any way to guarantee a release of the mutex, even in case of such a crash?Also how would I handle a crash of the other process, which might not have released the mutex yet? Do I need to handle AbandonedMutexException each tim

  • Heather
    c# serialization memory-mapped-files binaryformatter
    I’m trying to serialize my MMF to file and here is the code:class MMF {private const string filename = @”c:\NFS”;private long offset = 0;private long length = 194;private byte[] buffer;public MMF() {using (var mmf =MemoryMappedFile.CreateFromFile(filename, FileMode.OpenOrCreate, null, offset + length, MemoryMappedFileAccess.ReadWriteExecute)) {using (var accessor = mmf.CreateViewAccessor(offset, length, MemoryMappedFileAccess.ReadWriteExecute)) {buffer = new byte[194];/*FS fs = new FS();fs.Files

  • Kieren Johnstone
    c# performance debugging .net-4.0 memory-mapped-files
    I have a client/server app. The server component runs, uses WCF in a ‘remoting’ fashion (binary formatter, session objects).If I start the server component and launch the client, the first task the server does completes in <0.5sec.If I start the server component with VS debugger attached, and then launch the client, the task takes upwards of 20sec to complete.There are no code changes – no conditional compilation changes. The same occurs whether I have the server component compiled and runn

  • user997112
    c++ boost memory-mapped-files
    I am using the below code to open files which are approximately 400 to 800MB in size:#include <boost\interprocess\file_mapping.hpp> #include <boost\interprocess\mapped_region.hpp> #include <iostream> #include <vector> #include <string>using namespace boost::interprocess; using namespace std;int main(){file_mapping fm(“C:\\test\\1.txt”,read_only);mapped_region region(fm,read_only);const char* const data = static_cast<const char*>(region.get_address());const siz

  • Karussell
    java nio mmap memory-mapped-files
    I’ve a small and simple storage system which is accessible through memory mapped files. As I need to address more than 2GB space I need a list of MappedByteBuffer with a fixed size like 2GB (I’m using less for different reasons). Then all is relativly simple: a buffer maps to a certain space say to 1GB and when I need more I map a new MappedByteBuffer (the file automatically increases), then when I need more a third buffer is mapped etc. This just worked.But then I’ve read in the Java NIO book t

  • R. Martinho Fernandes
    c++ persistence memory-mapped-files pod
    Pointers cannot be persisted directly to file, because they point to absolute addresses. To address this issue I wrote a relative_ptr template that holds an offset instead of an absolute address.Based on the fact that only trivially copyable types can be safely copied bit-by-bit, I made the assumption that this type needed to be trivially copyable to be safely persisted in a memory-mapped file and retrieved later on.This restriction turned out to be a bit problematic, because the compiler genera

Web site is in building