Skip to content

Accordion Functionality Memory Leak #18296

@rosenthalj

Description

@rosenthalj

Describe the bug

The PrimeNG AccordionContent Component has a memory leak.

When navigating from a page that has a PrimeNG AccordionContent component a detached node occurs.

The problem can be reproduced using the PrimeNG Accordion demo. The memory leak was induced in PrimeNG v19

The video listed below demonstrates the issue.
Video Notes:

  1. At the start of the video, I refresh the page. This clears the page's memory
  2. In the Video I navigate away from the Accordion Demo Page 5 times
  3. I use the Chrome Development Tool's Memory Profiler to take a snapshot of the browsers JavaScript VM memory (profiling type = detached elements)
  4. Chrome has detected 5 detached elements
  5. At the end of the demo I navigate to the "about page" because this is a very simple page and sometimes Chrome's Memory Profile will identify additional detached elements that would have been removed during the execution of a page's destroy methods
    https://github.com/user-attachments/assets/081cbf43-2edc-4417-8d3f-dad97c1d7a88

The next video shows PrimeNG v17 Accordion Demo working properly. Note PrimeNg v17 doesn't have a AccordionContent Component but the Accordion functionality (and PrimeNG demo) is equivalent to v19.

AccordionV17Good.mov

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

No response

Reproducer

https://primeng.org/accordion

Environment

n/a

Angular version

19

PrimeNG version

v19

Node version

n/a

Browser(s)

all browsers

Steps to reproduce the behavior

  1. Goto the PrimeNG Accordion Demo: https://primeng.org/accordion
  2. Refresh the page
    -- this will reset the page's memory
  3. In the demo navigate away and back to the Accordion Demo
    -- only use links provided in the PrimeNG demo to navigate
  4. Open the Chrome Development Tools and take a snapshot of detached elements
  5. There will be one "Accordion" detached node for each time you navigated way from the Accordion Demo page

Expected behavior

No detached nodes
No memory leak

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugIssue contains a bug related to a specific component. Something about the component is not working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions