Skip to content

Memory leak when navigating away from DynamicFormControlContainerComponent – missing call to parent ngOnDestroy #4645

@jlipka

Description

@jlipka

Describe the bug

When using DsDynamicFormControlContainerComponent, which extends DynamicFormControlContainerComponent (from the ng-dynamic-forms library), navigating away from a form does not call the parent class's ngOnDestroy. This prevents proper cleanup of subscriptions, leading to memory accumulation over repeated form navigations (e.g., submitting “save for later” and reopening in a loop). The leak was demonstrated via memory snapshots taken in Firefox after ~10 cycles, showing increasing numbers of objects/arrays in memory.

Used a local version of DSpace v8 - but the bug seems to affect all current versions (7 / 8 / 9 / main-branch).

Web browser: Firefox (used for memory snapshot testing)

To Reproduce

  1. Navigate into a submission form that uses DsDynamicFormControlContainerComponent.
  2. Click “Save for later”, or navigate back by using the browser buttons, and then reopen the form.
  3. Repeat steps 1–2 about 10 times (as per testing scenario).
  4. Observe memory snapshots in your favorite browser.

Expected behavior

DsDynamicFormControlContainerComponent should call the parent implementation of ngOnDestroy from DynamicFormControlContainerComponent to ensure that any subscriptions are properly cleaned up.

Navigating away from the form and reopening it repeatedly should not result in a cumulative increase in memory usage over successive cycles.

Related work

#4644

Metadata

Metadata

Assignees

Type

Projects

Status

✅ Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions