Skip to content

Instantly share code, notes, and snippets.

@ryuichiueda
Last active February 9, 2026 08:30
Show Gist options
  • Select an option

  • Save ryuichiueda/682b837383da783e823078569810b8d3 to your computer and use it in GitHub Desktop.

Select an option

Save ryuichiueda/682b837383da783e823078569810b8d3 to your computer and use it in GitHub Desktop.
仮想メモリと確保された物理メモリの容量の違いの調査
#include <stdlib.h>
#include <unistd.h>
int main() {
char *p = malloc(1024*1024*1024); //1GiBメモリ確保
for(int i=0;i<1024*1024;i++) //最初の1MiBにデータ書き込み
p[i] = 111;
sleep(10000); //観察用にプログラムを止める
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment