Questions tagged [mmap]

mmap is a POSIX-compliant Unix system call that maps files or devices into memory.

mmap() creates a new mapping in the virtual address space of the calling process.

https://en.wikipedia.org/wiki/Mmap

1936 questions
11
votes
2 answers

Unmapping or 'release' a MappedByteBuffer under Android

The usual problem in Java is that you have to hack to get a proper unmapping of memory mapped files - see here for the 14year old bug report ;) But on Android there seems to be 0 solutions in pure Java and just via NDK. Is this true? If yes, any…
Karussell
  • 17,085
  • 16
  • 97
  • 197
11
votes
6 answers

Why doesn't POSIX mmap return a volatile void*?

Mmap returns a void*, but not a volatile void*. If I'm using mmap to map shared memory, then another process could be writing to that memory, which means two subsequent reads from the same memory location can yield different values -- the exact…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
11
votes
1 answer

Why use mmap over fread?

Why/when is it better to use mmap(), as opposed to fread()'ing from a filestream in chunks into a byte array? uint8_t my_buffer[MY_BUFFER_SIZE]; size_t bytes_read; bytes_read = fread(my_buffer, 1, sizeof(my_buffer), input_file); if (MY_BUFFER_SIZE…
tarabyte
  • 17,837
  • 15
  • 76
  • 117
11
votes
3 answers

Android NDK mmap call broken on 32-bit devices after upgrading to Lollipop

I'm trying to grab 784 MiB of memory. Yes, I know that is a lot for a 32-bit phone, but the following call worked before Android 5.0: mmap(0, 0x31000000, PROT_NONE, MAP_ANON | MAP_SHARED, -1, 0); However, on three different devices from different…
sigmabeta
  • 1,174
  • 1
  • 12
  • 28
11
votes
3 answers

Why mmap cannot allocate memory?

I ran the program with root priviledge but it keeps complaining that mmap cannot allocate memory. Code snippet is below: #define PROTECTION (PROT_READ | PROT_WRITE) #define LENGTH (4*1024) #ifndef MAP_HUGETLB #define MAP_HUGETLB…
drdot
  • 3,215
  • 9
  • 46
  • 81
11
votes
3 answers

JVM cant map reserved memory when running in Docker container

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,…
KayoticSully
  • 1,400
  • 5
  • 15
  • 30
11
votes
1 answer

Bad Linux Memory Mapped File Performance with Random Access C++ & Python

While trying to use memory mapped files to create a multi-gigabyte file (around 13gb), I ran into what appears to be a problem with mmap(). The initial implementation was done in c++ on Windows using boost::iostreams::mapped_file_sink and all was…
shao.lo
  • 4,387
  • 2
  • 33
  • 47
11
votes
1 answer

Segfault reading lazy bytestring past 2^18 bytes

Consider the following code: http://hpaste.org/90394 I am memory mapping a large 460mb file to a lazy ByteString. The length of the ByteString reports 471053056. When nxNodeFromID file 110000 is changed to a lower node ID, ie: 10000, it works…
kvanbere
  • 3,289
  • 3
  • 27
  • 52
11
votes
4 answers

Java OutOfMemory exception: mmap error on loading zip file

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…
Darya Dmitrichenko
  • 113
  • 1
  • 1
  • 6
11
votes
2 answers

How to use /dev/kmem?

Updated my post... I got below program. It operates on /dev/kmem and /dev/mem. I think I can learn something from the code. But when I run it on my Beagle Board, below result is given: case 1: ( if(1) ) root@omap:/home/ubuntu/tom# ./kmem_mem…
Tom Xue
  • 3,169
  • 7
  • 40
  • 77
10
votes
2 answers

Solr uses too much memory

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…
rjdevereux
  • 1,842
  • 2
  • 21
  • 35
10
votes
5 answers

Implementing your own malloc/free with mmap and munmap

I have implemented by own malloc and free using mmap. Now since unlike free, munmap also takes length as parameter, therefore I put length as an additional information in the mapped memory. The code for my malloc and free is shown below. I want to…
MetallicPriest
  • 29,191
  • 52
  • 200
  • 356
10
votes
3 answers

mmap and csv files

I am trying to understand how to use the package mmap to access large csv files. More precisely, I'd like to Create a mmap object from a csv file with mmap.csv(); Save the file created by mmap.csv() containing the data in binary format; Be able to…
Ryogi
  • 5,497
  • 5
  • 26
  • 46
10
votes
2 answers

Is mmap atomic?

Are mmap calls atomic in their effect? That is, does a mapping change made by mmap appear atomically to other threads accessing the affected region? As a litmus test, consider the case you do a mmap in a file of all zeros (from thread T1 which is…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
10
votes
3 answers

communicating between processes with shared-memory results zero-copy?

I am writing a network daemon, on Linux with kernel 2.6, which has one producer process and N of consumer processes, which does not make any change on the data, and does not create any response back to the producer. Whenever the producer process…
ddoman
  • 1,051
  • 1
  • 10
  • 12