Skip to content

Memory leak #115

@scottschafer

Description

@scottschafer

I don't know if this is at all an issue with react2angular, but I am experiencing some nasty leaks with a React component wrapped with react2angular. I have a workaround listed at the end, but it's ugly and I'd like to find a better solution.

My component looks like this:

export class EncounterView extends React.Component {
  memLeak = new Int8Array(100000000);
  componentWillUnmount() {
    debugger;
  }
  render() {
    return <h1>no-op</h1>;
  }
}

// Register component for AngularJS integration
module('talixCodingInsight')
  .component(
    'encounterView',
    react2angular(
      EncounterView
    )
  );

Then this component is embedded into my AngularJS app like this, hooked up with $stateProvider.state:

    <encounter-view></encounter-view>`,

The problem here is that when I go to this route and leave it, componentWillUnmount() is called but the buffer is not released.

Here are the retainers:

memLeak in EncounterView@711833 | 11 | 1360 % | 100 001 32852 %
stateNode in FiberNode@708915 | 10 | 2880 % | 100 001 61652 %
lastEffect in FiberNode@707329 | 9 | 2880 % | 100 007 13652 %
currentFiber in system / Context@90437 | 8 | 11 6080 % | 100 539 41652 %
context in overrideHookState()@68727 | 7 | 640 % | 1680 %

However, I did find a workaround. Which is nasty. The fix was to use ng-if to remove the component when changing the route. If I do that, then the buffer is released.

I don't like this solution though. Any ideas as to what's happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions