Angular 7 - 内存占用 / 泄漏?

4

将一个相当大的应用程序(约300-400个组件和许多提供者,@ngxs和@ngrx)从angular+angular/material从v6升级到v7而不改变其余代码后,我注意到了很多内存开销。

比较升级前后应用程序的两个内存转储,看起来像这样:

@angular v7应用程序的内存转储

@angular v6应用程序的内存转储

这些堆快照是在登录两个页面,导航到有很多事情发生的页面并在两个实例中刷新后拍摄的。在初始加载完成后,我拍摄了快照。

比较两个堆大小,v6和v7之间的差异始终是内存中(字符串)常量的差异。

有没有人已经注意到了相同的行为?有没有人有什么想法可以隔离问题?

我的package.json如下:

{
  "name": "cwa",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.conf.json",
    "build": "ng build",
    "test": "ng test",
    "lint": "./node_modules/.bin/nx lint && ng lint",
    "e2e": "ng e2e",
    "affected:apps": "./node_modules/.bin/nx affected:apps",
    "affected:build": "./node_modules/.bin/nx affected:build",
    "affected:e2e": "./node_modules/.bin/nx affected:e2e",
    "affected:test": "./node_modules/.bin/nx affected:test",
    "affected:lint": "./node_modules/.bin/nx affected:lint",
    "affected:dep-graph": "./node_modules/.bin/nx affected:dep-graph",
    "format": "./node_modules/.bin/nx format:write",
    "format:write": "./node_modules/.bin/nx format:write",
    "format:check": "./node_modules/.bin/nx format:check",
    "update": "ng update @nrwl/schematics",
    "update:check": "ng update",
    "workspace-schematic": "./node_modules/.bin/nx workspace-schematic",
    "dep-graph": "./node_modules/.bin/nx dep-graph",
    "help": "./node_modules/.bin/nx help",
    "affected": "./node_modules/.bin/nx affected"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.1.3",
    "@angular/cdk": "7.1.1",
    "@angular/common": "7.1.3",
    "@angular/compiler": "7.1.3",
    "@angular/core": "7.1.3",
    "@angular/flex-layout": "^7.0.0-beta.19",
    "@angular/forms": "7.1.3",
    "@angular/material": "7.1.1",
    "@angular/material-moment-adapter": "7.1.1",
    "@angular/platform-browser": "7.1.3",
    "@angular/platform-browser-dynamic": "7.1.3",
    "@angular/router": "7.1.3",
    "@ctrl/tinycolor": "^2.2.1",
    "@fortawesome/fontawesome-free": "^5.2.0",
    "@ngrx/effects": "7.0.0-beta.1",
    "@ngrx/store": "7.0.0-beta.1",
    "@ngrx/router-store": "7.0.0-beta.1",
    "@ngrx/store-devtools": "7.0.0-beta.1",
    "@ngx-translate/core": "^10.0.2",
    "@ngxs/devtools-plugin": "^3.3.2",
    "@ngxs/router-plugin": "^3.3.2",
    "@ngxs/storage-plugin": "^3.3.2",
    "@ngxs/store": "^3.3.2",
    "@nrwl/nx": "7.1.1",
    "angular-highcharts": "7.0.2",
    "core-js": "^2.5.4",
    "d3": "^3.5.17",
    "file-saver": "^1.3.8",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "highcharts": "^6.2.0",
    "immer": "^1.5.0",
    "moment": "^2.22.2",
    "ng2-charts": "^1.6.0",
    "ngrx-store-freeze": "0.2.4",
    "ngx-cookie-service": "^1.0.10",
    "outdated-browser-rework": "^2.6.1",
    "perfect-scrollbar": "^1.4.0",
    "rxjs": "6.3.3",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.11.0",
    "@angular-devkit/build-ng-packagr": "~0.11.0",
    "@angular/cli": "7.1.2",
    "@angular/compiler-cli": "7.1.3",
    "@angular/language-service": "7.1.3",
    "@nrwl/schematics": "7.1.1",
    "@types/d3": "3.5.34",
    "@types/highcharts": "^5.0.34",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-marbles": "0.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-firefox-launcher": "^1.1.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ng-packagr": "^4.2.0",
    "prettier": "1.15.2",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tsickle": ">=0.34.0",
    "tslib": "^1.9.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.6"
  }
}
1个回答

2

我有同样的问题。我设法将其隔离到rxjs版本6.3.3。我将其降级到6.3.2,似乎运行良好。我认为这可能与他们在github存储库上报告的此问题有关。

最初的回答: 我有相同的问题。我发现它是由于rxjs的版本6.3.3引起的。我将其降级到6.3.2后,问题似乎得到了解决。我认为这可能与他们在github托管服务中报告的这个问题有关。

这真的很疯狂,我的电脑将使用6GB的RAM,2GB的交换空间,然后在我意识到之前就崩溃了。 - Melroy van den Berg
不起作用 :( - JRichardsz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接