Skip to content

[Bug]: Gin-Vue-Admin 前端构建内存溢出错误报告 #2182

@AdamZay

Description

@AdamZay

gin-vue-admin 版本

v2.8.9

Node 版本

v18.20.8

Golang 版本

1.24

是否依旧存在

可以

bug描述

执行 npm run build 时,在 rendering chunks (95) 阶段因内存耗尽而崩溃。
vite v6.4.1 building for production...
✓ 2580 modules transformed.
rendering chunks (95)...
<--- Last few GCs --->
[38762:0xb57400000] 27492 ms: Mark-sweep 2009.2 (2086.5) -> 1995.5 (2088.7) MB, 1020.0 / 0.0 ms allocation failure; scavenge might not succeed
[38762:0xb57400000] 28454 ms: Mark-sweep 2011.3 (2088.7) -> 1997.6 (2091.0) MB, 947.4 / 0.0 ms allocation failure; scavenge might not succeed

<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

修改建议

错误堆栈(前几行):
1: 0x10285b400 node::Abort() [/Users/wans/.nvm/versions/node/v18.20.8/bin/node]
2: 0x10285b5e4 node::ModifyCodeGenerationFromStrings(...)
3: 0x1029dfce8 v8::internal::V8::FatalProcessOutOfMemory(...)
4: 0x102bb57c8 v8::internal::EmbedderStackStateScope::EmbedderStackStateScope(...)
5: 0x102bb9114 v8::internal::Heap::CollectSharedGarbage(...)
6: 0x102bb63fc v8::internal::Heap::PerformGarbageCollection(...)
7: 0x102bb3534 v8::internal::Heap::CollectGarbage(...)
8: 0x102ba7f08 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(...)
9: 0x102ba8754 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(...)
10: 0x102b8df30 v8::internal::Factory::NewFillerObject(...)
11: 0x102f4b708 v8::internal::Runtime_AllocateInYoungGeneration(...)

内存使用情况:

构建过程中内存占用持续接近 2GB(峰值约 2011 MB),最终超出 Node 默认内存限制导致崩溃。

本地尝试:

已尝试切换 Node 18 并设置 NODE_OPTIONS=--max-old-space-size=4096,但问题依旧(日志显示仍逼近 2GB,似乎内存限制未生效或项目本身需要更大内存)。

用16G的内存也是同样不行。

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions