memory-mapped-files

Mapped c++ struct to c# struct

我们两清 提交于 2019-12-11 19:42:27
问题 I am having trouble mapping the following c++ struct in c# for memory mapping purposes. typedef struct { DWORD Data1; DWORD Data2; double AverageData[2]; DWORD NumData[2]; } DIRECTIONAL_STATS; typedef struct { DIRECTIONAL_STATS DirectionStats[2]; char Name[100]; int StatLength; } OTHER_STATS; typedef struct { OTHER_STATS SystemStat[64][2]; long LastUpdate; }STATS; Can someone please shed some lights on how to achieve the mapping? Mapping from c++ type to c# type is fine for me. However, I don

MemoryMappedViewStream error “does not have appropriate access”

久未见 提交于 2019-12-11 15:43:37
问题 I am trying to create a MMF-backed collection that dynamically expands up to 2GB. I wanted to be able to read existing items at the same time new items are being added. It works great on my development machine but I am getting an error on some machines: The thread tried to read from or write to a virtual address for which it does not have the appropriate access. Has anyone seen this error before? I am likely doing something wrong with the way I am handling MemoryMappedFiles, I'm creating a

MemoryMappedFile: Unable to find the specified file

不羁岁月 提交于 2019-12-11 12:24:47
问题 I'm having trouble getting the MemoryMappedFile pattern to work. I have a directory with 25 excel spreadsheets that I want to load using MemoryMappedFile. The MemoryMappedFile.CreateFromFile works just fine, but when I call MemoryMappedFile.OpenExisting(lender) , it reads the first 3 files, and then on the 4th attempt, it fails with exception: Unable to find the specified file. public static void Main() { var files = System.IO.Directory.EnumerateFiles(@"lendersheets", "*.xls*").ToList();

Streaming from memory mapped files in Qt

拟墨画扇 提交于 2019-12-11 10:08:34
问题 Is there any way to create a data stream that is located at the beginning of a memory mapped file in Qt? Once i use QFile::map method, i get a uchar* . So is there any way to initialize a data stream with it? Thanks in advance! 回答1: I've not tried it but there's a QDataStream::readRawData() function that accepts a char * and a length which you should be able to pipe that uchar * into. That'll give you your stream. 来源: https://stackoverflow.com/questions/12065879/streaming-from-memory-mapped

Memory Mapping the same file multiple times?

荒凉一梦 提交于 2019-12-11 08:24:09
问题 What are the performance characteristics of memory mapping the same file multiple times? Will the OS reuse/cache between the mappings or will it read in the file multiple times into different parts of the memory? i.e. if I read and write to a memory mapped file from two different processes will it go through the disk or will they communicate in memory? If I read from a memory mapped file from two different process alternatively thread, will they read from the same memory? 回答1: You can use MAP

(Address boundary error) in Haskell application

一笑奈何 提交于 2019-12-11 07:52:00
问题 I'm trying to develop haskell replacement for less pager. Full code is here https://github.com/purpleP/pager.git buildInitialState :: IO TuiState buildInitialState = do (file : args) <- getArgs bs <- mmapFileByteStringLazy file Nothing pure (TuiState (V.fromList (BC.lines bs)) 0) That's how I read file. It works fine with files of 20Mb but doesn't work for 100Mb file. Am I doing something wrong or is this a bug in mmap library? terminated by signal SIGSEGV (Address boundary error) Is the

Reading from/Writing to Byte Arrays in C# .net 4

假如想象 提交于 2019-12-11 06:55:39
问题 Greetings Overflowers, I love the flexibility of memory mapped files in that you can read/write any value type. Is there a way to do the same with byte arrays without having to copy them into for e.g. a memory map buffers ? Regards 回答1: You can use the BitConverter class to convert between base data types and byte arrays. You can read values directly from the array: int value = BitConverter.ToInt32(data, pos); To write data you convert it to a byte array, and copy it into the data:

Memory-mapping a file in Windows with SHARE attribute (so file is not locked against deletion)

爷,独闯天下 提交于 2019-12-10 19:51:24
问题 Is there any way to map a file's content into memory in Windows that does not hold a lock on the file (in particular, such that the file can be deleted while still mmap'd)? The Java NIO libraries mmap files in Windows in such a way that the mapped file cannot be deleted while there is any non garbage collected MappedByteBuffer reference left in the heap. The JDK team claim that this is a limitation of Windows, but only when files are mmap'd, not when they are opened as regular files: https:/

Using boost::iostreams mapped_file_source and filtering_streambuf to decompress file

青春壹個敷衍的年華 提交于 2019-12-10 18:22:34
问题 I plan to process large compressed files and I would like to memory map the files to speedup reading. I adopted the existing example with regular file input but cannot get it either compile nor work :-) I'm using C++ Boost 1.49 Any suggestion welcome! #include<iostream> #include<boost/iostreams/filtering_streambuf.hpp> #include<boost/iostreams/copy.hpp> #include<boost/iostreams/filter/zlib.hpp> #include<boost/iostreams/device/file.hpp> #include<boost/iostreams/device/mapped_file.hpp> void

load np.memmap without knowing shape

情到浓时终转凉″ 提交于 2019-12-10 17:14:14
问题 Is it possible to load a numpy.memmap without knowing the shape and still recover the shape of the data? data = np.arange(12, dtype='float32') data.resize((3,4)) fp = np.memmap(filename, dtype='float32', mode='w+', shape=(3,4)) fp[:] = data[:] del fp newfp = np.memmap(filename, dtype='float32', mode='r', shape=(3,4)) In the last line, I want to be able not to specify the shape and still get the variable newfp to have the shape (3,4) , just like it would happen with joblib.load . Is this