memory-mapped-files

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

会有一股神秘感。 提交于 2019-12-22 02:56:32
问题 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? 回答1: They have some samples here. EDIT I think this would provide the answer. Basically, it would seem some sort of memory pointer is required for memory-mapped files, and not a file system path. 回答2: You can use the GetMappedFileName function to get the path to a memory mapped file when it is mapped. This of

Is there really no mremap in Darwin?

白昼怎懂夜的黑 提交于 2019-12-22 01:43:52
问题 I'm trying to find out how to remap memory-mapped files on a Mac (when I want to expand the available space). I see our friends in the Linux world have mremap but I can find no such function in the headers on my Mac. /Developer/SDKs/MacOSX10.6.sdk/usr/include/sys/mman.h has the following: mmap mprotect msync munlock munmap but no mremap man mremap confirms my fears. I'm currently having to munmap and mmmap if I want to resize the size of the mapped file, which involves invalidating all the

numpy.memmap for an array of strings?

和自甴很熟 提交于 2019-12-21 17:57:28
问题 Is it possible to use numpy.memmap to map a large disk-based array of strings into memory? I know it can be done for floats and suchlike, but this question is specifically about strings. I am interested in solutions for both fixed-length and variable-length strings. The solution is free to dictate any reasonable file format. 回答1: If all the strings have the same length, as suggested by the term "array", this is easily possible: a = numpy.memmap("data", dtype="S10") would be an example for

Write string data to MemoryMappedFile

…衆ロ難τιáo~ 提交于 2019-12-20 14:36:52
问题 I am following this tutorial here I am having a hard time figuring out how to get a string "THIS IS A TEST MESSAGE" to store in the memory mapped file and then pull it out on the other side. The tutorial says to use byte array. Forgive me I am new to this and trying on my own first. Thanks, Kevin ##Write to mapped file using System; using System.IO.MemoryMappedFiles; class Program1 { static void Main() { // create a memory-mapped file of length 1000 bytes and give it a 'map name' of 'test'

Write string data to MemoryMappedFile

我只是一个虾纸丫 提交于 2019-12-20 14:36:00
问题 I am following this tutorial here I am having a hard time figuring out how to get a string "THIS IS A TEST MESSAGE" to store in the memory mapped file and then pull it out on the other side. The tutorial says to use byte array. Forgive me I am new to this and trying on my own first. Thanks, Kevin ##Write to mapped file using System; using System.IO.MemoryMappedFiles; class Program1 { static void Main() { // create a memory-mapped file of length 1000 bytes and give it a 'map name' of 'test'

C# code very slow with debugger attached; MemoryMappedFile's fault?

爷,独闯天下 提交于 2019-12-20 12:38:35
问题 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

Expanding Java Memory-Mapped Byte Buffer

£可爱£侵袭症+ 提交于 2019-12-20 12:28:40
问题 Is there a way to expand the Java memory-mapped byte buffer such that the new size is reflected back to the mapped file on disk? 回答1: No, you will need to adjust the size of the underlying file and recreate the Memory Mapped Byte Buffer. RandomAccessFile file = new RandomAccessFile(/* some file */); MappedByteBuffer buffer = file.getChannel().map(MapMode.READ_WRITE, 0, file.length()); // Some stuff happens... // adjust the size file.setLength(newLength); // recreate the memory mapped buffer

Optimal storage of data structure for fast lookup and persistence

夙愿已清 提交于 2019-12-20 10:11:13
问题 Scenario I have the following methods: public void AddItemSecurity(int itemId, int[] userIds) public int[] GetValidItemIds(int userId) Initially I'm thinking storage on the form: itemId -> userId, userId, userId and userId -> itemId, itemId, itemId AddItemSecurity is based on how I get data from a third party API, GetValidItemIds is how I want to use it at runtime. There are potentially 2000 users and 10 million items. Item id's are on the form: 2007123456, 2010001234 (10 digits where first

How to allocate and free aligned memory in C

让人想犯罪 __ 提交于 2019-12-20 08:40:00
问题 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 obsolete?) memalign function, which can be freed using free. 回答1: Here is a solution, which encapsulates the call to malloc, allocates a bigger buffer for alignment

Memory mapped file java NIO

瘦欲@ 提交于 2019-12-19 04:14:34
问题 I understand how to create a memory mapped file, but my question is let's say that in the following line: FileChannel roChannel = new RandomAccessFile(file, "r").getChannel(); ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, SIZE); Where i set SIZE to be 2MB for example, does this means that it will only load 2MB of the file or will it read further in the file and update the buffer as i consume bytes from it? 回答1: Where i set SIZE to be 2MB for example, does this means that