无法收听本地主机,内存不足

Posted

技术标签:

【中文标题】无法收听本地主机,内存不足【英文标题】:Cannot listen to localhost, heap out of memory 【发布时间】:2021-11-08 17:53:45 【问题描述】:

我的设置

操作系统:Linux Mint 20.1 x86_64

节点版本:v14.16.1

首先我用 git 克隆了项目。

然后用npm install安装deps

之后我使用npm run dev 运行服务器,但服务器挂起,无法监听 localhost:3000

> my-apps@1.0.0 dev /home/roby/web
> sapper dev

在我等待大约 4-5 分钟后,这个错误发生了。

<--- Last few GCs --->

[1913:0x62fb080]   239094 ms: Scavenge (reduce) 946.8 (954.8) -> 946.2 (954.8) MB, 7.4 / 0.0 ms  (average mu = 0.287, current mu = 0.210) allocation failure 
[1913:0x62fb080]   239166 ms: Scavenge (reduce) 946.8 (952.0) -> 946.5 (953.5) MB, 20.0 / 0.0 ms  (average mu = 0.287, current mu = 0.210) allocation failure 
[1913:0x62fb080]   240769 ms: Mark-sweep (reduce) 947.3 (955.5) -> 945.5 (955.5) MB, 1542.4 / 0.1 ms  (average mu = 0.234, current mu = 0.173) allocation failure scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - javascript heap out of memory
 1: 0xa04200 node::Abort() [node]
 2: 0x94e4e9 node::FatalError(char const*, char const*) [node]
 3: 0xb7978e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xb79b07 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xd34395  [node]
 6: 0xd34f1f  [node]
 7: 0xd42fab v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 8: 0xd46b6c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 9: 0xd0c472 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
10: 0xd062f4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [node]
11: 0xd08641 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [node]
12: 0xd0b1e5 v8::internal::FactoryBase<v8::internal::Factory>::NewConsString(v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, v8::internal::AllocationType) [node]
13: 0x1098490 v8::internal::Runtime_StringAdd(int, unsigned long*, v8::internal::Isolate*) [node]
14: 0x1401219  [node]
Aborted (core dumped)
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! my-apps@1.0.0 dev: `sapper dev`
npm ERR! Exit status 134
npm ERR! 
npm ERR! Failed at the my-apps@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/roby/.npm/_logs/2021-09-13T12_20_18_036Z-debug.log

我已经尝试了名为 increase-memory-limit 的 npm 包来增加内存限制,但它没有用。 我也试过这个命令,但仍然失败set NODE_OPTIONS=--max_old_space_size=4096

【问题讨论】:

【参考方案1】:

试试这个

export NODE_OPTIONS="--max-old-space-size=5120"

或使用您提到的导出关键字

export set NODE_OPTIONS=--max_old_space_size=4096

【讨论】:

尝试将节点版本降级到 12.. 它可能会工作。

以上是关于无法收听本地主机,内存不足的主要内容,如果未能解决你的问题,请参考以下文章

无法执行脚本:内存不足,无法继续执行程序

windows7打不开图片显示内存不足

使用 Nuxt auth 和 axios 时 Javascript 堆内存不足

错误:接近堆限制的无效标记压缩分配失败 - JavaScript 堆内存不足

以太坊geth:内存不足

电脑上看图片显示内存不足