mmap

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

南楼画角 提交于 2019-11-30 19:17:58
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 periodically atomically updates a pointer 'p' to point to a valid node with positive reference count. Readers

Solr uses too much memory

∥☆過路亽.° 提交于 2019-11-30 18:34:58
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 Tomcat fixed the problem temporarily, but it eventually came back. We then tried decreasing the JVM size to

munmap() failure with ENOMEM with private anonymous mapping

岁酱吖の 提交于 2019-11-30 17:15:53
I have recently discovered that Linux does not guarantee that memory allocated with mmap can be freed with munmap if this leads to situation when number of VMA (Virtual Memory Area) structures exceed vm.max_map_count . Manpage states this (almost) clearly: ENOMEM The process's maximum number of mappings would have been exceeded. This error can also occur for munmap(), when unmapping a region in the middle of an existing mapping, since this results in two smaller mappings on either side of the region being unmapped. The problem is that Linux kernel always tries to merge VMA structures if

Trying to write to an int in shared memory (using mmap) with a child process

痞子三分冷 提交于 2019-11-30 15:20:20
I'm playing around with some code that requires communication between a parent and a forked child process. I've created an int in shared memory before the fork, but any changes I make with the child process don't seem to affect the int when accessed by the parent process. Here's a piece of code that illustrates my problem. int * shared = mmap(NULL, sizeof(int), PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); pid_t child; int childstate; if((child=fork())==0){ *shared = 1; exit(0); } waitpid (child, &childstate, 0); printf("%d",*shared); Although the child process sets the value of

JVM cant map reserved memory when running in Docker container

只谈情不闲聊 提交于 2019-11-30 13:23:07
问题 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

Java OutOfMemory exception: mmap error on loading zip file

a 夏天 提交于 2019-11-30 12:24:28
I run my app on production env (rhel 5.2 x64, oracle jre 1.7_05, tomcat 7.0.28) with JVM arguments: -Xms8192m -Xmx8192m -XX:MaxPermSize=1024m -Doracle.net.tns_admin=/var/ora_net -XX:ReservedCodeCacheSize=512m -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -XX:+UseStringCache -XX:+OptimizeStringConcat -XX:+UseCompressedOops -XX:+UseG1GC -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9026 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false After several time i've got stack trace like that: Java HotSpot(TM) 64-Bit Server VM warning:

Why is MAP_GROWSDOWN mapping does not grow?

南楼画角 提交于 2019-11-30 09:17:34
问题 I tried to create MAP_GROWSDOWN mapping with the expectation it would grow automatically. As specified in the manual page: MAP_GROWSDOWN This flag is used for stacks. It indicates to the kernel virtual memory system that the mapping should extend downward in memory. The return address is one page lower than the memory area that is actually created in the process's virtual address space. Touching an address in the "guard" page below the mapping will cause the mapping to grow by a page . This

app性能

 ̄綄美尐妖づ 提交于 2019-11-30 08:39:33
性能获取办法 appium+webview context + execute script +perfmance api appium/selenium的ExecuteScript Api 注入js: return JSON.stringify(window.performance.timing) JSON.stringify(window.performance.getEntriesByName(document.querySelector("img").src[0],null,2) { "name": "https://testerhome.com/system/letter_avatars/2/A/226_95_81/64.png", "entryType": "resource", "startTime": 277.4149999895599, "duration": 0, "initiatorType": "img", "nextHopProtocol": "", "workerStart": 0, "redirectStart": 0, "redirectEnd": 0, "fetchStart": 277.4149999895599, "domainLookupStart": 277.4149999895599, "domainLookupEnd": 277

Does malloc() use brk() or mmap()?

末鹿安然 提交于 2019-11-30 08:32:53
c code: // program break mechanism // TLPI exercise 7-1 #include <stdio.h> #include <stdlib.h> void program_break_test() { printf("%10p\n", sbrk(0)); char *bl = malloc(1024 * 1024); printf("%x\n", sbrk(0)); free(bl); printf("%x\n", sbrk(0)); } int main(int argc, char **argv) { program_break_test(); return 0; } When compiling following code: printf("%10p\n", sbrk(0)); I get warning tip: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int’ Question 1: Why is that? And after I malloc(1024 * 1024) , it seems the program break didn't change. Here is the output: 9b12000

Reading a file to string with mmap

风格不统一 提交于 2019-11-30 07:33:02
I'm trying to read a file to a string using mmap. I was following this example: http://www.lemoda.net/c/mmap-example/index.html My code looks like this unsigned char *f; int size; int main(int argc, char const *argv[]) { struct stat s; const char * file_name = argv[1]; int fd = open (argv[1], O_RDONLY); /* Get the size of the file. */ int status = fstat (fd, & s); size = s.st_size; f = (char *) mmap (0, size, PROT_READ, 0, fd, 0); for (i = 0; i < size; i++) { char c; c = f[i]; putchar(c); } return 0; } But I always receive a segemation fault when accessing f[i]. What am I doing wrong? strace