-
-
Notifications
You must be signed in to change notification settings - Fork 350
observer function leaks memory on the server #140
Comments
@doctyper not a solution, but note that that not unmounting the |
Hm, I'm not sure how accurate that statement is. We incorporated MobX into react-wildcat a few weeks ago, and within the hour we observed an enormous amount of leaked memory that was not being garbage collected. The leak was mitigated when I added the fix to bail on the server. |
@doctyper what would you think about having a global mobxReact setting, that changes this behavior on the fly? This is because trying to detect it automatically might interfer with Jest / Enzyme tests etc that are run 'server side'. For example: |
I think that flag would work well. On Wed, Nov 2, 2016 at 3:57 PM, Michel Weststrate notifications@github.com
-Matt Ruby- |
As long as it's opt-in, yes that would work well indeed. |
Released as |
Wrapping a component in
observer()
leaks memory when rendering universally. This is due tocomponentWillMount
creating a reaction that is never disposed, sincecomponentWillUnmount
is not called on the server.My current workaround involves avoiding wrapping a component in
observer()
when rendering on the server. This works, but obviously it's not an elegant solution:An easy solution is to bail on the server on
componentWillMount
, though I'm not sure if there would be side-effects in doing so. Let me know if you'd like me to attempt a PR.The text was updated successfully, but these errors were encountered: