node.js - 在 nodejs 的底层发生了什么?
问题描述
考虑这段伪代码:
i = 0;
while i < int.maxvalue {
print(i)
i += 1
}
在其中运行此代码时,nodejs
它开始吃掉我的 RAM 并在 2 GB 处被压碎,而在garbage collector
我尝试过的任何其他语言(ruby、python、java)上,它们吃掉了 ~3..~15 MB 的 RAM。
只是为了了解幕后发生的事情,我想问 - 为什么它在 nodejs 中会这样工作?
更新:python上的真实代码:
import sys
i = 0
while i < sys.maxint:
print(i)
i += 1
对于节点:
let i = 0;
while(i<Number.MAX_VALUE){
console.log(i);
i += 1;
}
解决方案
推荐阅读
- c++ - 如何在exe中找到字符串?
- typescript - 这个条件怎么是假的?
- django - 为什么apiary发出的API测试无法通过Django的request.POST处理?
- php - 单击第 2 页的链接后,Laravel 分页重定向到主路由
- javascript - 我想创建一个空数组稍后填充
- python - 'ElementNotVisibleException' 无法单击带有 Selenium 的按钮
- c# - 我的脚本无法按预期工作,它还会使统一编辑器崩溃
- spring - 仅在设置了特定的弹簧配置文件时才运行集成测试
- python - 如何仅选择数值数据类型并将它们保存在python中的数组中?
- javascript - 将单选按钮更改为下拉菜单