Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ng-if memory leak #11618

Closed
Closed
@astalker

Description

@astalker

I've noticed a possible memory leak with the ng-if directive. It appears to be failing to garbage collect HTML Elements.

I've set up two fiddles to compare ng-if with ng-show (which doesn't have the same issue).

ng-show - http://jsfiddle.net/neridum/8vo7ae8L/
ng-if - http://jsfiddle.net/neridum/hptt8wmu/

I simulated this by running a Heap Allocation profile and clicking between the views a few times (Incognito in Chrome Canary). With ng-if there is a left over HTMLDivElement that looks to be detached.

This doesn't appear to be for a specific version and is apparent with 1.2.1, 1.3.9 and 1.3.15.

I found a Stackoverflow post suggesting to run a cleanup method but I'm not sure that this is a suitable approach - http://stackoverflow.com/questions/26022481/ng-if-causing-memory-leak-in-angular-js

A related issue to this is #9748

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions