我以为我永远不会这么说。我想让我的机器运行超慢。
这是我想这样做的方式:我想在 F# (Array.init) 中分配一个大数组。它应该如此之大,以至于对数组的随机访问应该会产生页面错误。我有 4GB RAM,并在 64 位模式下运行。当我分配 2^29 个 4 字节整数时,运行时会引发内存不足异常。
> Array.init (1 <<< 28) (fun i->i);;
val it : int [] =
[|0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20;
21; 22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39;
40; 41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58;
59; 60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77;
78; 79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96;
97; 98; 99; ...|]
> Array.init (1 <<< 29) (fun i->i);;
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at <StartupCode$FSI_0003>.$FSI_0003.main@()
Stopped due to error
>