[問題] mmap memory issue

看板LinuxDev作者 (JACK)時間16年前 (2009/12/18 17:52), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
請問一下 我去開hello這個檔案 但是free一下 並沒有減少 4M空間(4000000) 還有為什麼p 要宣告成int呢 #include <stdlib.h> #include <sys/mman.h> #include <fcntl.h> int main(void) { int *p; int fd = open("hello", O_RDWR); if (fd < 0) { perror("open hello"); exit(1); } p = mmap(NULL, 4000000, PROT_WRITE, MAP_SHARED, fd, 0); if (p == MAP_FAILED) { perror("mmap"); exit(1); } close(fd); p[0] = 0x30313233; munmap(p, 6); return 0; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.230.134.126
文章代碼(AID): #1BAr3f9N (LinuxDev)
討論串 (同標題文章)
文章代碼(AID): #1BAr3f9N (LinuxDev)