Code Monkey home page Code Monkey logo

Comments (4)

scottschafer avatar scottschafer commented on July 23, 2024 1

To @liquidprogrammer , the fix looked something like this in the template:

      <encounter-view
        id="encounter-view-ng"
        ng-if="$ctrl.includeEncounterView"

Where EncounterView is the react2angular component.

Then when changing states away from this route, I set includeEncounterView to false and wait until the view is torn down before proceeding to the route.

      $scope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams) => {
        if (toState.name !== 'home.patients.details.coding.encounter') {
          this.includeEncounterView = false;
          if ($('#encounter-view-ng').length) {
            event.preventDefault();

            const checkTornDownInterval = $interval(() => {
              if (!$('#encounter-view-ng').length) {
                $interval.cancel(checkTornDownInterval);
                $state.go(toState, toParams);
              }
            }, 0);
          }
        }

@brianunlam, It's been a while since I looked at this. SInce I reported this bug, I discovered that React seems to hang onto references and free them periodically. This means that you might need to take a memory snapshot, perform an operation that shouldn't leak and then WAIT before taking another snapshot - if you do this too quickly, you might see leaks that don't really exist.

But in this case, it did seem like the memory was steadily increasing. I don't know, this leak/non-leak was driving me a little bit crazy. Now I have code that I'm afraid to touch. ;)

I asked about React hanging onto references here BTW:
https://stackoverflow.com/questions/58984601/reactdom-seems-to-be-caching-and-releasing-elements-so-is-this-a-leak

Thanks for a great and useful library. I don't think it's the culprit here.

from react2angular.

liquidprogrammer avatar liquidprogrammer commented on July 23, 2024

Hi @scottschafer! Im facing the same issue, can u please provide an example of ur hacky ng-if fix? I tried do that ng-if hack somewhere on the top level of routing, but memory was still leaked (but less than without that). Just wanted to double check where in the app u apply that trick so it helps to avoid leaks

from react2angular.

brianunlam avatar brianunlam commented on July 23, 2024

@scottschafer how did you do to get the leaks that way?

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 %

from react2angular.

liquidprogrammer avatar liquidprogrammer commented on July 23, 2024

@scottschafer hi, thanks! I'll try that out. I didn't try to ng-if the component itself, i only tried to add ng-if at the top level root component, but that helped only a bit.

from react2angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.