Issue 1:
Please goto this uploaded project to reproduce

https://github.com/nhhockeyplayer/build-beta

Here is TSC output (thanks for taking a look)

C:\apache-tomcat-8.0.23\webapps\ROOT\new\gulp.connect>tsc

node_modules/angular2/src/core/change_detection/parser/locals.d.ts(3,14): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/change_detection/parser/locals.d.ts(4,42): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/debug/debug_node.d.ts(14,13): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/debug/debug_node.d.ts(24,17): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/debug/debug_node.d.ts(25,17): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/di/provider.d.ts(436,103): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/di/provider.d.ts(436,135): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/render/api.d.ts(13,13): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/core/render/api.d.ts(14,84): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(1,25): error TS2304: Cannot find name 'MapConstructor'.

node_modules/angular2/src/facade/collection.d.ts(2,25): error TS2304: Cannot find name 'SetConstructor'.

node_modules/angular2/src/facade/collection.d.ts(4,27): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(4,39): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(7,9): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(8,30): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(11,43): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(12,27): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(14,23): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(15,25): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/collection.d.ts(95,41): error TS2304: Cannot find name 'Set'.

node_modules/angular2/src/facade/collection.d.ts(96,22): error TS2304: Cannot find name 'Set'.

node_modules/angular2/src/facade/collection.d.ts(97,25): error TS2304: Cannot find name 'Set'.

node_modules/angular2/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/lang.d.ts(14,17): error TS2304: Cannot find name 'Set'.

node_modules/angular2/src/facade/lang.d.ts(78,59): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/facade/promise.d.ts(1,10): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(3,14): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(8,32): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(9,38): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(10,35): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(10,93): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(11,34): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(12,32): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(12,149): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/facade/promise.d.ts(13,43): error TS2304: Cannot find name 'Promise'.

node_modules/angular2/src/http/headers.d.ts(43,59): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/http/url_search_params.d.ts(11,16): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/platform/browser/browser_adapter.d.ts(75,33): error TS2304: Cannot find name 'Map'.

node_modules/angular2/src/platform/dom/dom_adapter.d.ts(85,42): error TS2304: Cannot find name 'Map'.

node_modules/rxjs/CoreOperators.d.ts(35,67): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/CoreOperators.d.ts(50,66): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/CoreOperators.d.ts(89,67): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/CoreOperators.d.ts(94,38): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/CoreOperators.d.ts(94,50): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(46,62): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(47,42): error TS2304: Cannot find name 'Iterator'.

node_modules/rxjs/Observable.d.ts(103,74): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(103,84): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(143,66): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(158,65): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(201,66): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(206,38): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/Observable.d.ts(206,50): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/observable/ForkJoinObservable.d.ts(6,50): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/observable/ForkJoinObservable.d.ts(7,58): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/observable/FromObservable.d.ts(7,38): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/observable/FromObservable.d.ts(7,51): error TS2304: Cannot find name 'Iterator'.

node_modules/rxjs/observable/PromiseObservable.d.ts(9,31): error TS2304: Cannot find name 'Promise'.

node_modules/rxjs/observable/PromiseObservable.d.ts(10,26): error TS2304: Cannot find name 'Promise'.

Issue 2:
I'm submitting a ... (check one with "x")

[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

When triggering ComponentRef.destroy(), no browser memory is ever released. Any injected dependencies are all still there and running, even though the component is gone.

Also:

When bootstrapping an app within an iframe, destroying that app and removing the iframe from the DOM does not release browser memory.

In both of these scenarios, browser memory builds up over time and the browser tab and angular app lock up or crash. Injected dependencies are created, but never removed.

Expected behavior

Browser memory should be released as apps and components are destroyed.

Minimal reproduction of the problem with instructions

STEPS TO REPRODUCE

REPRODUCING DEPENDENCY LEAK

Run the Tour of Heroes plnkr in Chrome or IE

https://plnkr.co/edit/R9axXVtjep5VO8hWygpA?p=preview

Open the js console and watch the logging in the hero service, which does not stop after destroying the app.

Note, this is the Tour of Heroes example, except that after the app is bootstrapped in main.ts, I've added a 15sec timer that runs ref.destroy(). Additionally, in the hero.service.ts file, I added a console log in the constructor that prints every second. You can see that the service continues to run even after triggering .destroy() on the component ref.

REPRODUCING IFRAME LEAK

Run the Tour of Heroes live example in IE 11

https://angular.io/resources/live-examples/toh-6/ts/eplnkr.html

Open F12 dev tools, click on Memory and click "Start profiling to begin a performance session"

Make changes to the files by adding line breaks. Every time the app reloads in the iframe the memory will grow. After about 15 minutes of this the app will lock up due to the IE tab hitting the 1.5Gb memory limit. If you test with app that has more dependencies, it will lock up much faster.

This can be reproduced in Chrome too, it just takes longer for the memory leak to build up that much.

What is the motivation / use case for changing the behavior?

Large-scale angular apps that use iframes or rely on destroying components will leak memory over time and eventually crash or lock up.

Please tell us about your environment:

Mac OS 10.11.6

Angular version: 2.0.X

Angular v2.4.1

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

all

Language: [all | TypeScript X.X | ES6/7 | ES5]

all

Node (for AoT issues): node --version =