# JS 构建也会内存溢出

**URL:** <https://www.isharkfly.com/t/js/2615>\
**Category:** DevOps\
**Tags:** jenkins, javascript\
**Created:** [December 4, 2026, 5:00am UTC](https://www.isharkfly.com/t/js/2615 "2026-12-04T05:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [December 4, 2026, 5:00am UTC](https://www.isharkfly.com/t/js/2615/1 "2026-12-04T05:00:00Z")

</div>

3000 多个页面也会内存溢出：

```auto

<--- Last few GCs --->

[2504578:0x2a5e5000] 601485 ms: Scavenge 3897.6 (4109.7) -> 3886.4 (4099.1) MB, pooled: 41 MB, 11.69 / 0.34 ms (average mu = 0.275, current mu = 0.338) allocation failure; 
[2504578:0x2a5e5000] 603359 ms: Mark-Compact 3902.3 (4115.2) -> 3854.1 (4064.1) MB, pooled: 48 MB, 1666.41 / 0.12 ms (average mu = 0.324, current mu = 0.368) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xe36196 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 2: 0x123f4a0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 3: 0x123f777 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0x146d1a5 [node]
 5: 0x146d1d3 [node]
 6: 0x148628a [node]
 7: 0x1489458 [node]
 8: 0x1cc6071 [node]
Aborted (core dumped)
[ELIFECYCLE] Command failed with exit code 134.

```

 ![2026-12-04_14-36-21](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/4/c/4c271eea4d6e5765a597a61f928370665b6f2499.jpeg)

Jenkins 需要调整内存分配。

Jenkins 的环境变量需要增加到 8G。

```auto
        // 中英文共 3000 多个页面，VitePress 构建会超出 Node 默认约 4 GB 的堆上限（JavaScript heap out of memory）
        NODE_OPTIONS = '--max-old-space-size=8192'

```

 ![2026-12-04_14-38-14](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/6/4/644cba09c3ae016df96059bbbe709ebbe0fcc66c.jpeg)

文件越多，构建时候消耗的内存越多。
