mmap

Fast resize of a mmap file

☆樱花仙子☆ 提交于 2019-11-30 07:08:09
I need a copy-free re-size of a very large mmap file while still allowing concurrent access to reader threads. The simple way is to use two MAP_SHARED mappings (grow the file, then create a second mapping that includes the grown region) in the same process over the same file and then unmap the old mapping once all readers that could access it are finished. However, I am curious if the scheme below could work, and if so, is there any advantage to it. mmap a file with MAP_PRIVATE do read-only access to this memory in multiple threads either acquire a mutex for the file, write to the memory

JVM cant map reserved memory when running in Docker container

ぐ巨炮叔叔 提交于 2019-11-30 06:58:41
I cant seem to run java at all in a Docker container on my server. Even when issuing java -version , I get the following error. root@86088d679103:/# java -version OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000035ce1000000, 2555904, 1) failed; error='Operation not permitted' (errno=1) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 2555904 bytes for committing reserved memory. # An error report file with more information is saved as: # //hs_err_pid17.log According to this, java can't map 2.5Mb of

mmap slower than getline?

亡梦爱人 提交于 2019-11-30 05:27:26
I face the challenge of reading/writing files (in Gigs) line by line. Reading many forum entries and sites (including a bunch of SO's), mmap was suggested as the fastest option to read/write files. However, when I implement my code with both readline and mmap techniques, mmap is the slower of the two. This is true for both reading and writing. I have been testing with files ~600 MB large. My implementations parse line by line and then tokenize the line. I will present file input only. Here is the getline implementation: void two(char* path) { std::ios::sync_with_stdio(false); ifstream pFile

Delete / Insert Data in mmap'ed File

♀尐吖头ヾ 提交于 2019-11-30 05:27:22
I am working on a script in Python that maps a file for processing using mmap(). The tasks requires me to change the file's contents by Replacing data Adding data into the file at an offset Removing data from within the file (not whiting it out) Replacing data works great as long as the old data and the new data have the same number of bytes: VDATA = mmap.mmap(f.fileno(),0) start = 10 end = 20 VDATA[start:end] = "0123456789" However, when I try to remove data (replacing the range with "") or inserting data (replacing the range with contents longer than the range), I receive the error message:

Does mmap or malloc allocate RAM?

血红的双手。 提交于 2019-11-30 05:18:05
I know this is probably a stupid question but i've been looking for awhile and can't find a definitive answer. If I use mmap or malloc (in C, on a linux machine) does either one allocate space in RAM? For example, if I have 2GB of RAM and wanted to use all available RAM could I just use a malloc/memset combo, mmap , or is there another option I don't know of? I want to write a series of simple programs that can run simultaneously and keep all RAM used in the process to force swap to be used, and pages swapped in/out frequently. I tried this already with the program below, but it's not exactly

mmap( ) vs read( )

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 05:17:08
I'm writing a bulk ID3 tag editor in C. ID3 tags are usually at the beginning of an mp3 encoded file, although older (version 1) tags are at the end. The app is designed to accept a directory and frame ID list from the command line, then recurse the directory structure updating all the ID3 tags it finds. The user may additionally choose to remove all older (version 1) tags. Another option is to simply display the current tags, without performing an update. The directory might contain 2 files or 2 million. If the user means to update the files, I was planning to load the entire file into memory

How does mmap work?

为君一笑 提交于 2019-11-30 04:00:19
I am working on programs in Linux which needs mmap file from harddrive, but i have a question, what can make it fail. Like if all the memories are fragmented, which has only 200M each, but i want to mmap a file to a memory of 1000M, will it succeed?? And another question, are there any tools in linux for recollect memory like some tools in Windows, e.g. the built-in tool for xp. Thanks. mmap() uses addresses outide your program's heap area, so heap fragmentation isn't a problem, except to the extent that it can make the heap take up more space, and reduce the available space for mappings. If

Is it possible to store pointers in shared memory without using offsets?

只谈情不闲聊 提交于 2019-11-30 03:48:42
问题 When using shared memory, each process may mmap the shared region into a different area of its respective address space. This means that when storing pointers within the shared region, you need to store them as offsets of the start of the shared region. Unfortunately, this complicates use of atomic instructions (e.g. if you're trying to write a lock free algorithm). For example, say you have a bunch of reference counted nodes in shared memory, created by a single writer. The writer

Solr uses too much memory

为君一笑 提交于 2019-11-30 03:18:49
问题 We have a Solr 3.4 instance running on Windows 2008 R2 with Oracle Java 6 Hotspot JDK that becomes unresponsive. When we looked at the machine, we noticed that the available physical memory went to zero. The Tomcat7.exe process was using ~70Gigs (Private Working Set) but Working Set (Memory) was using all the memory on the system. There were no errors in the Tomcat / Solr logs. We used VMMap to identify that the memory was being used for memory mapping the Solr segement files. Restarting

堆学习---1 宏观观察

倖福魔咒の 提交于 2019-11-29 23:48:51
动态内存的分配和释放最重要的就是malloc 和 free 这两个函数 一个是用于向操作系统索取动态的内存空间 一个是用于释放之前通过malloc或者relloc函数分配的空间。其 内部通过brk,sbrk和mmap 实现对内存的索取。 举个例子 当malloc(1024)的时候 即我们只需要1024Bytes,但是进程会向操作系统先批发一块大的内存块,又因为是主线程所以称为 main arena 它是一块非常大的 连续内存区域 紧邻在bss,即未初始化数据的下方 下面的图直接展示了它是在主线程的下方 开辟了 132KB大的空间 。之后的再次提交malloc之类的动态内存申请的时候,就会 先使用该arena直到消耗完这片连续的内存区域 。 当消耗完该块arena后,程序可以通过增加相应的 break location 即数据段高度(通过brk()和sbrk()实现) 并且会伴随着 Top Chunk 的变化 当使用free函数释放内存的时候 堆区域并不会立即被释放掉 而是会被添加这个 被free的区块到main arena的bin中 在glibc中 释放所需的数据结构跟bin这个数据结构有关 。 当之后用户再次请求动态内存的时候就不必先向操作系统提交请求,而是先从bin中找有木有合适的chunk,当区块均不合适的时候,才会向操作系统提交申请 多线程下的heap段