最近,我分别在Rust/Golang/Swift/Ocaml/Python/PHP这几个语言里面测试了 存储一个有 1 0000 0000 个整数列表 ,分别需要多大的空间。
Rust 表现最好,只需要300MB.
Golang 需要734MB.
Swift 需要 1GB.
Python 需要 3GB.
PHP 需要 13.75GB内存..... ( 并且执行时间超过 20秒, python 只需要 2秒 )
以下是 Fibjs 的内存占用,截至程序崩溃,fibjs 需要内存 530 多 MB.
➜ Linux_Release git:(master) ./fibjs test_mem.js
<--- Last few GCs --->
1140 ms: Mark-sweep 958.4 (995.3) -> 575.9 (612.8) MB, 77.3 / 0 ms (+ 0.0 ms in 1 steps since start of marking, biggest step 0.0 ms) [allocation failure] [GC in old space requested].
1241 ms: Mark-sweep 575.9 (612.8) -> 575.9 (612.8) MB, 100.7 / 0 ms [allocation failure] [GC in old space requested].
1337 ms: Mark-sweep 575.9 (612.8) -> 575.9 (612.8) MB, 96.3 / 0 ms [last resort gc].
1439 ms: Mark-sweep 575.9 (612.8) -> 575.9 (612.8) MB, 101.5 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x1c94a4e36619 <JS Object>
2: /* anonymous */ [test_mem.js:~1] [pc=0x31515ea7784a] (this=0x2f3f38c9e869 <an Object with map 0x2660c25065c9>,require=0x2f3f38c10ec9 <JS Function (SharedFunctionInfo 0x2f3f38c10e39)>,run=0x2f3f38c11069 <JS Function (SharedFunctionInfo 0x2f3f38c10fd9)>)
==== Details ================================================
[2]: /* anonymous */ [test_mem.js:~1] [pc=0x31515ea7784a] (this=0x2f3f38c...
#
# Fatal error in CALL_AND_RETRY_LAST
# Allocation failed - process out of memory
#