You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "plainheart (via GitHub)" <gi...@apache.org> on 2024/07/15 09:27:44 UTC
[PR] perf(line): reduce runtime memory cost [echarts]
plainheart opened a new pull request, #20161:
URL: https://github.com/apache/echarts/pull/20161
## Brief Information
This pull request is in the type of:
- [ ] bug fixing
- [ ] new feature
- [x] others
### What does this PR do?
Prebind the context of the `_changePolyState` function to the current instance of `LineView` rather than create a new function to reduce runtime memory cost.
### Fixed issues
- #20151
## Details
| [Before](https://echarts.apache.org/examples/editor.html?code=G4QwTgBARiDOCmEC8EDUA7eB3CAREALvABQBMADAIwAsANBAJz0DMAlANwBQokA9pvgCeyCKWoQAVBGYA2cuUkRK88lx4QAJoUQoA2gF014TYRAjdAWUIALAHRgQ6DbwC2xVosoBWcoe7H0XhwUTBx8ImIYBA5OADMAV3QAYwIAS34IEA0NcJBiWGtU2IIPAG9OCAhA4IhdatsAc3gCADF4gBt2gE14cHd6eqaCC34Ca3c0JQGgxubwklZ9WwArXlT0YgByAHpNmMqtIlsAB3iC4mr9kwIQE7Px4isx-0dnNw8AWghyW2oPKWUk0OIF0wNs7Xg6AaYwgX0o-iuRQg-UKxTKFUq13gtgKRQI7i4mOut1xxQJGIAvhjqiJQnhtMQMNh6RFLpN-PAhDEqbFeJBiOpUiJKOwIEKADxKeSi1KoVDoypZHKmclU3jHNIZFDlSoADwAgrrUrAAFwQHWYgiCY7wM2bJLaBp8wSbWgYypQXiJLRgQQAcRAxzNsRA7QQbqJwLNh3glIjEEEhuNZotHq9TnA_sDZt05Homx8AFJNvp45UrTa7aB2vF4Js4xiEGBUvBTbV3eaO5V0CAXLaIJtAAhGgBK5V1diAV_ubdrrOtlzGwFy8XhjM0EMC1-eVbbbCAWACqAGUACoAQnP49gghcnvadvgLg1ggAwqkwEkIWOiZVYDckgBrO0QC_b9wF6Q8rQhFNx27PkXFDFMqW_CAKS3Ylo1MDskIgfROApLgEAIABJdAiDAatiASZJNXQZEFUybJcmIddayuFwX2scACBxZoAHkNXSDZUwgA0jTbYSDlMDCiCw-cmxbNtdHHCTMR7Ps7RHEDkKjYlx2wypcMqCluXoHxyA4IA&version=5.5.1)
| [After](https://echarts.apache.org/examples/editor.html?code=G4QwTgBARiDOCmEC8EDUA7eB3CAREALvABQBMADAIwAsANBAJz0DMAlANwBQokA9pvgCeyCKWoQAVBGYA2cuUkRK88lx4QAJoUQoA2gF014TYRAjdAWUIALAHRgQ6DbwC2xVosoBWcoe7H0XhwUTBx8ImIYBA5OADMAV3QAYwIAS34IEA0NcJBiWGtU2IIPAG9OCAhA4IhdatsAc3gCADF4gBt2gE14cHd6eqaCC34Ca3c0JQGgxubwklZ9WwArXlT0YgByAHpNmMqtIlsAB3iC4mr9kwIQE7Px4isx-0dnNw8AWghyW2oPKWUk0OIF0wNs7Xg6AaYwgX0o-iuRQg-UKxTKFUq13gtgKRQI7i4mOut1xxQJGIAvhjqiJQnhtMQMNh6RFLpN-PAhDEqbFeJBiOpUiJKOwIEKADxKeSi1KoVDoypZHKmclU3jHNIZFDlSoADwAgrrUrAAFwQHWYgiCY7wM2bJLaBp8wSbWgYypQXiJLRgQQAcRAxzNsRA7QQbqJwLNh3glIjEEEhuNZotHq9TnA_sDZt05Homx8AFJNvp45UrTa7aB2vF4Js4xiEGBUvBTbV3eaO5V0CAXLaIJtAAhGgBK5V1diAV_ubdrrOtlzGwFy8XhjM0EMC1-eVbbbCAWACqAGUACoAQnP49gghcnvadvgLg1ggAwqkwEkIWOiZVYDckgBrO0QC_b9wF6Q8rQhFNx27PkXFDFMqW_CAKS3Ylo1MDskIgfROApLgEAIABJdAiDAatiASZJNXQZEFUybJcmIddayuFwX2scACBxZoAHkNXSDZUwgA0jTbYSDlMDCiCw-cmxbNtdHHCTMR7Ps7RHEDkKjYlx2wypcMqCluXoHxyA4IA&version=PR-20161) |
| :----: | :----: |
|  |  |
## Document Info
One of the following should be checked.
- [x] This PR doesn't relate to document changes
- [ ] The document should be updated later
- [ ] The document changes have been made in apache/echarts-doc#xxx
## Misc
### ZRender Changes
- [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
### Related test cases or examples to use the new APIs
See the online [demo](https://echarts.apache.org/examples/editor.html?code=G4QwTgBARiDOCmEC8EDUA7eB3CAREALvABQBMADAIwAsANBAJz0DMAlANwBQokA9pvgCeyCKWoQAVBGYA2cuUkRK88lx4QAJoUQoA2gF014TYRAjdAWUIALAHRgQ6DbwC2xVosoBWcoe7H0XhwUTBx8ImIYBA5OADMAV3QAYwIAS34IEA0NcJBiWGtU2IIPAG9OCAhA4IhdatsAc3gCADF4gBt2gE14cHd6eqaCC34Ca3c0JQGgxubwklZ9WwArXlT0YgByAHpNmMqtIlsAB3iC4mr9kwIQE7Px4isx-0dnNw8AWghyW2oPKWUk0OIF0wNs7Xg6AaYwgX0o-iuRQg-UKxTKFUq13gtgKRQI7i4mOut1xxQJGIAvhjqiJQnhtMQMNh6RFLpN-PAhDEqbFeJBiOpUiJKOwIEKADxKeSi1KoVDoypZHKmclU3jHNIZFDlSoADwAgrrUrAAFwQHWYgiCY7wM2bJLaBp8wSbWgYypQXiJLRgQQAcRAxzNsRA7QQbqJwLNh3glIjEEEhuNZotHq9TnA_sDZt05Homx8AFJNvp45UrTa7aB2vF4Js4xiEGBUvBTbV3eaO5V0CAXLaIJtAAhGgBK5V1diAV_ubdrrOtlzGwFy8XhjM0EMC1-eVbbbCAWACqAGUACoAQnP49gghcnvadvgLg1ggAwqkwEkIWOiZVYDckgBrO0QC_b9wF6Q8rQhFNx27PkXFDFMqW_CAKS3Ylo1MDskIgfROApLgEAIABJdAiDAatiASZJNXQZEFUybJcmIddayuFwX2scACBxZoAHkNXSDZUwgA0jTbYSDlMDCiCw-cmxbNtdHHCTMR7Ps7RHEDkKjYlx2wypcMqCluXoHxyA4IA&version=5.5.1)
## Others
### Merging options
- [ ] Please squash the commits into a single one when merging.
### Other information
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] perf(line): reduce runtime memory cost [echarts]
Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #20161:
URL: https://github.com/apache/echarts/pull/20161#issuecomment-2228064561
Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
The pull request is marked to be `PR: author is committer` because you are a committer of this project.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] perf(line): reduce runtime memory cost [echarts]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20161:
URL: https://github.com/apache/echarts/pull/20161#issuecomment-2228077015
The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?version=PR-20161@86db174
<!-- ECHARTS_PR_PREVIEW -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] perf(line): reduce runtime memory cost [echarts]
Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #20161:
URL: https://github.com/apache/echarts/pull/20161#issuecomment-2235285112
Congratulations! Your PR has been merged. Thanks for your contribution! 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] perf(line): reduce runtime memory cost [echarts]
Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart merged PR #20161:
URL: https://github.com/apache/echarts/pull/20161
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
Re: [PR] perf(line): reduce runtime memory cost [echarts]
Posted by "100pah (via GitHub)" <gi...@apache.org>.
100pah commented on PR #20161:
URL: https://github.com/apache/echarts/pull/20161#issuecomment-2233732870
Just some extra records of this case:
It seems to be caused by:
```js
const oldData = this._data;
// ...
const changePolyState = (toState: DisplayState) => {
this._changePolyState(toState);
};
data.eachItemGraphicEl(function (el) {
el && ((el as ECElement).onHoverStateChange = changePolyState);
});
```
A closure of `changePolyState` references to `oldData`, and `oldData` references to the previous `changePolyState`s.
As a result, all of the `oldData`s are not released.
<img width="431" alt="image" src="https://github.com/user-attachments/assets/515047a5-058e-49eb-978b-d24c996bc26a">
---
Theoretically, it's need to check whether is kind of case occurs in other `render` functions that contain `oldData` and element listener.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org