Skip to content
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

fix leak on server side, not store singleton instance to global object #100

Merged
merged 1 commit into from
Aug 10, 2016

Conversation

kaesonho
Copy link
Contributor

@kaesonho kaesonho commented Aug 6, 2016

@lingyan @redonkulus

we are storing rootI13nNode and reactI13nInstance on the global object, which causes memory leak, we are leaking all the i13n react component in memory on server side, because they eventually have a reference to the rootI13nNode

the solution here is just let setupI13n create that instance and pass it through context,
so that each I13n component can still get the instance.
also rootI13nNode can just store in the reactI13n instance.

After the change, we can see there's no leaking on i13nNodes now
screen shot 2016-08-08 at 10 42 52 am

@yahoocla
Copy link

yahoocla commented Aug 6, 2016

CLA is valid!

@coveralls
Copy link

coveralls commented Aug 6, 2016

Coverage Status

Coverage decreased (-0.1%) to 90.777% when pulling ad3be89 on fixleak into ce36e52 on master.

@@ -26,6 +25,7 @@ if ('client' === ENVIRONMENT) {
* @param {Object} options.rootModelData model data of root i13n node
* @param {Object} options.i13nNodeClass the i13nNode class, you can inherit it with your own functionalities
* @param {String} options.scrollableContainerId id of the scrollable element that your components
* @param {String} options.context context object
Copy link
Member

@lingyan lingyan Aug 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it clear this is the component context, and link to fluxible doc for component context.

@coveralls
Copy link

coveralls commented Aug 6, 2016

Coverage Status

Coverage decreased (-0.1%) to 90.777% when pulling 4cda8d9 on fixleak into ce36e52 on master.

@coveralls
Copy link

coveralls commented Aug 6, 2016

Coverage Status

Coverage remained the same at 90.909% when pulling 015f419 on fixleak into ce36e52 on master.

@kaesonho kaesonho changed the title use context as global object to fix leak on server side [WIP]use context as global object to fix leak on server side Aug 6, 2016
@kaesonho kaesonho changed the title [WIP]use context as global object to fix leak on server side use context as global object to fix leak on server side Aug 6, 2016
@coveralls
Copy link

coveralls commented Aug 6, 2016

Coverage Status

Coverage increased (+0.04%) to 90.953% when pulling 291d189 on fixleak into ce36e52 on master.

@kaesonho kaesonho changed the title use context as global object to fix leak on server side fix leak on server side, not store singleton instance to global object Aug 6, 2016
@coveralls
Copy link

coveralls commented Aug 8, 2016

Coverage Status

Coverage increased (+0.1%) to 91.013% when pulling 65e5a54 on fixleak into ce36e52 on master.

@kaesonho
Copy link
Contributor Author

kaesonho commented Aug 8, 2016

@lingyan @redonkulus @longlho updated, please check again.

@coveralls
Copy link

coveralls commented Aug 8, 2016

Coverage Status

Coverage increased (+0.1%) to 91.013% when pulling dea7f24 on fixleak into ce36e52 on master.

parentI13nNode: this._i13nNode
}
parentI13nNode: this._i13nNode,
reactI13nInstance: this._getReactI13n()
Copy link
Member

@lingyan lingyan Aug 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document how people can use this new context field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is internally usage, we use this context to pass reactI13n instance(and the i13n root) across components, do we want users to know this?

@kaesonho
Copy link
Contributor Author

kaesonho commented Aug 9, 2016

@lingyan @redonkulus updated, I rollbacked the breaking change, added document for the new version change, will do a minor version bump.

@coveralls
Copy link

coveralls commented Aug 9, 2016

Coverage Status

Coverage decreased (-0.3%) to 90.59% when pulling 2a6c84b on fixleak into ce36e52 on master.

@kaesonho kaesonho force-pushed the fixleak branch 2 times, most recently from 1d9d2d7 to 9203666 Compare August 9, 2016 04:21
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 90.59% when pulling 9203666 on fixleak into 858e80a on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 89.731% when pulling 9203666 on fixleak into 858e80a on master.

@@ -27,6 +27,15 @@ var I13nDempApp = setupI13n(DemoApp, {
}, [someReactI13nPlugin]);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like you are missing closing back ticks for the example. This messes up formatting below.


What we do with `setupI13n` is that we will create the `ReactI13n` instance, along with a root node of the I13nTree, passing them via component context to the children.

It's designed to work within React components, you should be able to just [utilFuctions](https://github.com/yahoo/react-i13n/blob/master/docs/guides/utilFunctions.md) and trigger i13n events. In case you want to do this out of React components, you can access `window._reactI13nInstance` directly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to just use utilFunctions

@kaesonho
Copy link
Contributor Author

kaesonho commented Aug 9, 2016

updated @redonkulus @lingyan please check

@coveralls
Copy link

coveralls commented Aug 9, 2016

Coverage Status

Coverage decreased (-0.7%) to 89.731% when pulling 8754f9c on fixleak into 858e80a on master.

@redonkulus
Copy link
Contributor

👍

@coveralls
Copy link

coveralls commented Aug 10, 2016

Coverage Status

Coverage decreased (-1.2%) to 89.185% when pulling f5a6a90 on fixleak into 858e80a on master.

@lingyan
Copy link
Member

lingyan commented Aug 10, 2016

:shipit:

@kaesonho kaesonho merged commit 9e5392f into master Aug 10, 2016
@kaesonho kaesonho deleted the fixleak branch August 10, 2016 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants