- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
如果您使用 mmap() 对文件进行内存映射,但随后底层文件的大小变小了很多。如果您访问从文件中删除的内存偏移量,会发生什么情况?
最佳答案
IBM 说它是未定义的 http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Fmmap.htm
If the size of the mapped file is decreased after mmap(), attempts to reference beyond the end of the file are undefined and may result in an MCH0601 exception.
If the size of the file increases after the mmap() function completes, then the whole pages beyond the original end of file will not be accessible via the mapping.
在 SingleUnixSpecification: http://pubs.opengroup.org/onlinepubs/7908799/xsh/mmap.html 中也是这样说的
If the size of the mapped file changes after the call to mmap() as a result of some other operation on the mapped file, the effect of references to portions of the mapped region that correspond to added or removed portions of the file is unspecified.
“未定义”或“未指定”表示 - 允许操作系统开始格式化磁盘或任何东西。最有可能是 SIGSEGV 杀死了您的应用程序。
关于c++ - mmap() : what happens if underlying file changes (shrinks)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6875771/
我想了解 mmap 的工作原理。mmap 的用户级调用如下所示。 void *mmap(void *addr, size_t len, int prot, int flags, int
我正在做一个Bottle驱动程序,我使用 yield 关键字和 mmap.mmap 对象在输出流中发送多个映射文件,如以下代码所示: for mapping in mappings: yield
我来自 C++/RAII 世界。 所以我对何时以及如何调用 mmap.close() 感到困惑[不是 file.close()]。 或者,根本不调用它?会不会漏气? 至于来自 document 的示例
我正在我的大学上操作系统类(class),我们的任务之一是使用 mmap 实现简单的 malloc。现在我开始工作了,我尝试使用 valgrind 来检测遗留的任何错误。不管是否释放内存,valgri
有谁知道 mmap(2) 和 mmap(3) 的区别是什么?手册第 3 节被描述为“本章描述了除第 2 章中描述的实现系统调用的库函数之外的所有库函数。” mmap(3) 不执行系统调用吗? 阅读这两
我不知道我在理解mmap时错过了哪些知识。我就是想不通。但让我这样问我的问题: 我有很多(例如 3 个)文件 block ,其大小分别为 s1、s2、s3。 s1、s2 和 s3 均小于 Mmap (
在 Linux 下: #free -m total used free shared buffers cachedMem:
我正在尝试将 C 库(beaglebone PRU 驱动程序 prussdrv.c)与 Python 连接。我想要访问的特定函数返回一个 mmap 指针,如下所示: int __prussdrv_me
当我调用mmap时: ptr = mmap(NULL, ...); 并要求系统提供一个缓冲区并将文件映射到其中,然后使用 再次调用 mmap ptr2 = mmap(ptr, ...); 尝试
在 Android 上用 Java 内存映射一个大文件效果很好。但是当映射总数超过 ~1.5GB 时,即使有多个映射调用,它也会失败: mmap failed: ENOMEM (Out of memo
我在具有 64G 内存和大量磁盘空间的 debian-64 上运行一个专门的数据库守护进程。它使用磁盘上的哈希表(mmaped)并通过定期 write() 调用将实际数据写入文件。当进行大量更新时,m
C++代码: #include #include #include #include #include using namespace std; #define FILE_MODE (S_I
我想处理一个由 4Kb block 组成的文件。 随着事情的发生,我将编写更多数据并映射新部分,取消映射我不再需要的部分。 当要映射的文件数据总量约为 4Gb 时,仅 4Kb 的 map() 是否太小
大家好,我正在尝试将下面的代码转换为 python(访问树莓派 1Mhz 计时器),我不知道什么时候要映射对象,我们需要 + TIMER_OFFSET (timer = (long long int
我所做的是一个垃圾收集器,使用mmap(2)为用户空间分配空间,这就要求最初分配时可以从任何地方开始,但是后面的分配地址应该是与之前的分配连续,如下所示: page_size = getpagesiz
众所周知,最重要的 mmap() 功能是在许多进程之间共享文件映射。但众所周知,每个进程都有自己的地址空间。 问题是内存映射文件(更具体地说,它的数据)真正保存在哪里,以及进程如何访问这些内存? 我的
什么限制了内存映射文件的大小?我知道它不能大于未分配地址空间的最大连续块,并且应该有足够的可用磁盘空间。但是还有其他限制吗? 最佳答案 您太保守了:内存映射文件可能大于地址空间。 查看 内存映射文件的
如果我使用 mmap 来编写 uint32_t,我会遇到大端/小端约定的问题吗?特别是,如果我在 big-endian 机器上写入一些数据 mmap,当我尝试在 little-endian 机器上读取
所以,对于我最后一年的项目,我使用 Video4Linux2 从相机中提取 YUV420 图像,将它们解析为 x264(本地使用这些图像),然后通过 Live555 将编码流发送到 RTP/RTCP通
是 mmap在它们的效果中调用原子? 也就是说,是否由 mmap 进行了映射更改以原子方式出现在访问受影响区域的其他线程中? 作为试金石,请考虑您执行 mmap 的情况。在一个全为零的文件中(来自线程
我是一名优秀的程序员,十分优秀!