`
wbj0110
  • 浏览: 1598385 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

test linux virtual memory max size

阅读更多
/**
* $Id: mmap.cpp 1595 2012-07-28 10:33:18Z shijia.wxr $
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
 
#define MMAP_FILE_SIZE (1024 * 1024 * 1024)
 
int main(int argc, char** argv)
{
int i = 0;
 
for(i = 1; ; i++) {
char filePath[64] = {0};
sprintf(filePath, "%d", i);
int fd = open(filePath, O_RDWR | O_CREAT);
if(fd < 0) {
printf("open failed\n");
break;
}
ftruncate(fd, MMAP_FILE_SIZE);
 
void* p = mmap(0, MMAP_FILE_SIZE, PROT_WRITE, MAP_SHARED,fd, 0);
if(p != 0) {
memset(p, 0, MMAP_FILE_SIZE);
printf("mmap OK, %d\n", i);
} else {
printf("mmap Failed, exit.\n");
break;
}
}
 
while (1) {
printf("sleeping\n");
sleep(1);
}
 
return 0;
}
分享到:
评论

相关推荐

    微软内部资料-SQL性能优化2

    Application memory tuning provides more of the computer's virtual memory to applications by providing less virtual memory to the operating system. Although a system having less than 2 GB of physical ...

    Too many open files 解决方法

    max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 7168 virtual memory ...

    使用多GPU训练模型.md

    x_test = preprocessing.sequence.pad_sequences(x_test, maxlen=MAX_LEN) MAX_WORDS = x_train.max() + 1 CAT_NUM = y_train.max() + 1 # 构建数据集 ds_train = tf.data.Dataset.from_tensor_slices((x_train, y...

    nodejs之VM的内存处理测试的demo

    3. **内存限制**:虽然V8会自动进行GC,但开发者可以通过设置`--max-old-space-size`等命令行参数来限制V8的最大旧空间大小,从而控制内存使用。在VM模块中,也可以通过设置`options.maxOldGenerationSize`来限制...

    Bochs - The cross platform IA-32 (x86) emulator

    - Determine and select max physical address size automatically at configure time: - 32-bit physical address for 386/486 guests - 36-bit physical address for PSE-36 enabled Pentium guest - 40-bit ...

    BobBuilder_app

    I deferred from testing the get test over 100 million record as it would require a huge array in memory to store the Guid keys for finding later, that is why there is a NT (not tested) in the table. ...

    opensc-0.12.0.tar.gz

    * use max_send_size 255 / max_recv_size 256 bytes by default. reduce this for some readers (e.g. scm) with t=0 cards. * increase pin buffer size to allow longer pin codes. * Windows Make.rules.mak ...

    mini2440 beer(pwm) 驱动

    Virtual kernel memory layout: vector : 0xffff0000 - 0xffff1000 ( 4 kB) fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) DMA : 0xffc00000 - 0xffe00000 ( 2 MB) vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB) ...

    FairyGUI-Unity-Plugin-3.4.0.zip

    - NEW: Add textfield maxwidth feature. - NEW: Add API to query package dependencies. - IMPROVED: Graphics module refactor. Now it is more convenient to create various shapes(pie, lines, polygon etc) ...

    python3.6.5参考手册 chm

    PEP 486: Make the Python Launcher aware of virtual environments PEP 488: Elimination of PYO files PEP 489: Multi-phase extension module initialization Other Language Changes New Modules typing ...

Global site tag (gtag.js) - Google Analytics