Skip to content

service prevents directive parent scope from being destroyed - opening for memory leak #304

@kyletheninja

Description

@kyletheninja

Before anything else I want to mention that this is a great directive and the only way this issue causes a true memory "leak" is if one is generating random pagination id's, which I would not recommend. However it will still cause memory bloat in any case in which the parent scope should be destroyed, until another instance with the same id is created.

The paginationService will prevent the parent scope of dirPagination from being garbage collected properly, because the directive's scope which is inherited from its parent is put onto an instance object in the instances map in paginationService by setCurrentPageParser. Thus if one is using multiple instances on multiple pages, all with unique ids, like I am, thumbing through your app will end up leaving every scope, basically all data from each page, in memory forever.

I am putting in a fix for my version, and I will upload it if anyone is interested. The paginationService just needs a deregisterInstance() method that gets called from dirPagination in a scope.$on('$destroy').

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions