关于资产优化的 Angular-cli 'JavaScript heap out of memory' [英] Angular-cli 'JavaScript heap out of memory' on asset optimization

查看:20
本文介绍了关于资产优化的 Angular-cli 'JavaScript heap out of memory'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Angular-cli 项目中创建传单地图.地图切片本地存储在资产"文件夹中,因为它是栅格地图.问题是当我有很多缩放级别的地图时,我有超过 280,000 张图像,大小约为 1.1 GB,而且它会变得更大.

I'm creating a leaflet map inside an Angular-cli project. Map tiles are stored locally in the 'assets' folder because it's a raster map. The problem is when I've many zoom levels of the map, I've more than 280 thousands images with approximate size of 1.1 GB and It will get bigger.

当我使用 ng serve 时,这里是控制台输出(卡在@assets optimization):

when I use ng serve here is the console output (it is stuck @ assets optimization):

** NG Live Development Server is running on http://localhost:4200. **
25234ms building modules
69ms sealing
0ms optimizing
0ms basic module optimization
96ms module optimization
1ms advanced module optimization
16ms basic chunk optimization
0ms chunk optimization
1ms advanced chunk optimization
0ms module and chunk tree optimization
179ms module reviving
9ms module order optimization
4ms module id optimization
6ms chunk reviving
23ms chunk order optimization
36ms chunk id optimization
61ms hashing
1ms module assets processing
149ms chunk assets processing
4ms additional chunk assets processing
0ms recording
1ms additional asset processing
2693ms chunk asset optimization
 94% asset optimization
<--- Last few GCs --->

  119106 ms: Mark-sweep 1333.6 (1409.7) -> 1333.6 (1415.7) MB, 1402.0 / 2.1 ms [allocation failure] [GC in old space requested].
  120570 ms: Mark-sweep 1333.6 (1415.7) -> 1333.6 (1427.7) MB, 1464.2 / 2.2 ms [allocation failure] [GC in old space requested].
  122079 ms: Mark-sweep 1333.6 (1427.7) -> 1340.0 (1409.7) MB, 1508.1 / 2.5 ms [last resort gc].
  123749 ms: Mark-sweep 1340.0 (1409.7) -> 1346.3 (1409.7) MB, 1670.2 / 2.1 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 000001AA792CFB61 <JS Object>
    1: inflight [C:Workspace
ode_modulesinflightinflight.js:~7] [pc=00000202BF9894B7] (this=000001AA792E6661 <JS Global Object>,key=00000045863E5881 <Strin
g[90]: lstatx00C:/Workspace/src/assets/leafletmap_files/9/42/176.png>,cb=00000045863E5839 <JS Function lstatcb_ (SharedFunctionInfo 00000253E9EFC219
)>)
    2: wrapper [C:Workspace...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

我尝试使用:node --max_old_space_size=8192 --optimize_for_size --max_executable_size=4096 --stack_size=4096,但是没有任何区别.

I tried using: node --max_old_space_size=8192 --optimize_for_size --max_executable_size=4096 --stack_size=4096, but It doesn't make any difference.

1- 有没有其他方法可以避免优化所有资产文件夹?如果我认为这是问题的根源,因为在添加更多传单平铺图像之前项目运行顺利.

1- Is there is any other way to avoid optimizing all the assets folder? If it is the source of the problem as I think, because the project were running smoothly before adding more leaflet tile images.

2- 有什么办法可以解决这个问题吗?

更新:Angular-cli 存储库 中存在与此问题相关的未解决问题.p>

UPDATE: There is an open issue at Angular-cli repository related to this question.

推荐答案

将以下行添加到 package.json 文件中.

Add the below line to package.json file.

"aot": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --prod --aot"

并尝试使用 npm run aot

它对我有用.

这篇关于关于资产优化的 Angular-cli 'JavaScript heap out of memory'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆