vue-vben-admin
vue-vben-admin copied to clipboard
vue-vben-admin编译太吃内存
描述 Bug
vue-vben-admin编译太吃内存
复现 Bug
开启sourcemap,服务器打包,直接崩溃
+ yarn build
yarn run v1.22.17
$ yarn clean:cache && npm run park
$ rimraf node_modules/.cache/ && rimraf node_modules/.vite
> [email protected] park
> cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts
vite v2.6.14 building for production...
transforming...
warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
<--- Last few GCs --->
[20091:0x642d350] 137533 ms: Scavenge 1853.9 (1904.4) -> 1850.8 (1904.9) MB, 6.3 / 0.0 ms (average mu = 0.363, current mu = 0.352) allocation failure
[20091:0x642d350] 137552 ms: Scavenge 1854.3 (1904.9) -> 1851.2 (1905.4) MB, 4.8 / 0.0 ms (average mu = 0.363, current mu = 0.352) allocation failure
[20091:0x642d350] 139739 ms: Mark-sweep 1854.9 (1905.4) -> 1849.9 (1913.7) MB, 2175.6 / 0.0 ms (average mu = 0.304, current mu = 0.233) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xb02ec0 node::Abort() [/root/.nvm/versions/node/v16.13.0/bin/node]
2: 0xa181fb node::FatalError(char const*, char const*) [/root/.nvm/versions/node/v16.13.0/bin/node]
3: 0xced88e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/root/.nvm/versions/node/v16.13.0/bin/node]
4: 0xcedc07 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/root/.nvm/versions/node/v16.13.0/bin/node]
5: 0xea5ea5 [/root/.nvm/versions/node/v16.13.0/bin/node]
6: 0xea6986 [/root/.nvm/versions/node/v16.13.0/bin/node]
7: 0xeb48be [/root/.nvm/versions/node/v16.13.0/bin/node]
8: 0xeb5300 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/root/.nvm/versions/node/v16.13.0/bin/node]
9: 0xeb827e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/root/.nvm/versions/node/v16.13.0/bin/node]
10: 0xe796aa v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/root/.nvm/versions/node/v16.13.0/bin/node]
11: 0x11f2e86 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/root/.nvm/versions/node/v16.13.0/bin/node]
12: 0x15e7879 [/root/.nvm/versions/node/v16.13.0/bin/node]
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
系统信息
- 操作系统: centos8、4Gb/8Gb内存都会 由此问题
- Node 版本: v16+
经过排查,编译的时候,占用8gb内存,这也太夸张了 不开启占用近4gb
切换到 node 14 最后一个版本试试
请问问题是否有解决呢,遇到了同样的问题,在服务器上编译失败了
我也遇到了这个问题,每次热更新都会吃满内存
- 操作系统:MacOs 内存16G
- Node版本:17.3.0
我的方法是利用 github 的 actions 自动构建和推送
有没有什么解决方案呀
同问,有没有解决方案
同问
liunx 设置环境变量
export NODE_OPTIONS=--max-old-space-size=32768
package.json
"build": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=32768 vite build && esno ./build/script/postBuild.ts",