-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Excessive use of memory and CPU #455
Comments
Are you setting a limit to the state history? |
Yes, but it also happens when the page is opened and only a few events are
fired (less than 5)
|
That is happening due to serialization of some huge objects included in the state or action. The solution is to sanitize them. |
This was with v2.15.2 from the Chrome store.. i'll keep digging see what's going on |
thanks @zalmoxisus, ui-router puts some big objects in the reducer, just took what I needed const actionSanitizer = action => {
const uiRouterActions = /@ui-router.+/g;
return uiRouterActions.test(action.type)
? { type: action.type, transition: sanitizeUIRouterTransition(action.transition) }
: action;
};
const stateSanitizer = (state: AppState): any => {
if (state.router && state.router.last && state.router.last) {
return {
...state,
router: sanitizeUIRouterTransition(state.router.last)
};
}
return state;
};
const sanitizeUIRouterTransition = (transition: Transition): any => ({
params: transition.router && transition.router.globals && transition.router.globals.params,
current: transition.router && transition.router.globals && transition.router.globals.current,
targetState: transition.targetState && transition.targetState().state(),
from: transition.from && transition.from(),
to: transition.to && transition.to()
});
const reduxDevtoolsExtensionOptions = {
actionSanitizer,
stateSanitizer
};
const composeEnhancers =
(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__(reduxDevtoolsExtensionOptions)) ||
compose; |
Thanks for the example! Added it to Troubleshooting. |
@zalmoxisus do you have a patreon or open collective for redux dev tool, I wish I had time to contribute but I don't, I would happily $ to encourage you, this extension is so important in the redux ecosystem |
OH, I just saw you have an open collective! I will contribute thanks! |
Thanks @phil-lgr! That example is also a contribution. Other contributions are also much appreciated, I'll use them to alloc more time in finishing https://github.com/zalmoxisus/redux-devtools-extension/projects |
Done, added my monthly contribution, BTW, I would put the open collective link higher in the README.md, it's long so I didn't noticed it, IMO no need to be shy for some $, put it right on top bro! 🥇 |
Thanks again! |
Before crashing it at least complains it is going to be slow and consume a huge amount of memory. That is described here: https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/Troubleshooting.md#excessive-use-of-memory-and-cpu In there is a link to a more useful example: zalmoxisus/redux-devtools-extension#455 Latest conversation seems to be here: zalmoxisus/redux-devtools-extension#619 Signed-off-by: michael sorens <msorens@chef.io>
Before crashing it at least complains it is going to be slow and consume a huge amount of memory. That is described here: https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/Troubleshooting.md#excessive-use-of-memory-and-cpu In there is a link to a more useful example: zalmoxisus/redux-devtools-extension#455 Latest conversation seems to be here: zalmoxisus/redux-devtools-extension#619 Signed-off-by: michael sorens <msorens@chef.io>
MacOS High Sierra 10.13.2 (17C205)
Chrome Version 63.0.3239.132 (Official Build) (64-bit)
Redux Devtools 2.15.1
Every time I inspect any Redux application, it uses up a considerable chunk of CPU and starts leaking memory.
I realise this is not enough information for debugging, but I would appreciate any thoughts on where to look for finding the leak?.
The text was updated successfully, but these errors were encountered: