The Wayback Machine - https://web.archive.org/web/20201123192402/https://github.com/c3js/c3/pull/2273
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

Memory leak fix #2273

Merged
merged 7 commits into from Feb 10, 2018
Merged

Memory leak fix #2273

merged 7 commits into from Feb 10, 2018

Conversation

@nazihahmed
Copy link
Contributor

@nazihahmed nazihahmed commented Jan 29, 2018

the detach event listener was not detached properly after calling .destroy
so I basically added resizeIfElementDisplayed to $$ (this), and detach the event listener properly
also .remove must be called on $$.resizeFunction on destroy,
anyways this fixed all my memory issue,
Fix #926

@nazihahmed
Copy link
Contributor Author

@nazihahmed nazihahmed commented Jan 30, 2018

we are waiting for the merge to happen so we can update our code base with yours,
pls release a new version to npm after these changes

@kt3k kt3k added this to the 0.5 milestone Feb 1, 2018
@@ -60,8 +60,7 @@
"node-sass": "^4.5.3",
"node-static": "^0.7.9",
"nodemon": "^1.11.0",
"rollup": "^0.55.0",

This comment has been minimized.

@kt3k

kt3k Feb 1, 2018
Member

I think rollup is necessary to build the bundled version (c3.js).

This comment has been minimized.

@nazihahmed

nazihahmed Feb 1, 2018
Author Contributor

It must be global because in the scripts where it's called you are using the global rollup command not from node modules, anyways i will add it back

.babelrc Outdated
@@ -0,0 +1,13 @@
{

This comment has been minimized.

@kt3k

kt3k Feb 1, 2018
Member

Because babel is configured in rollup.config.js (when bundling) and karma.conf.js (when testing), I think this file is not necessary and confusing.

This comment has been minimized.

@nazihahmed

nazihahmed Feb 1, 2018
Author Contributor

For me the build keeps returning an error from rollup until i added this file

This comment has been minimized.

@kt3k

kt3k Feb 1, 2018
Member

Do you use npm run command for invoking rollup?

npm run build command should invoke rollup (and other tools) with correct configs, like:

$ npm run build

> c3@0.4.18 build /Users/kt3k/t/c3
> npm run build:js && npm run build:css


> c3@0.4.18 build:js /Users/kt3k/t/c3
> npm run build:js:rollup && npm run build:js:uglify


> c3@0.4.18 build:js:rollup /Users/kt3k/t/c3
> rollup -c > c3.js

(!) Some options have been renamed
https://gist.github.com/Rich-Harris/d472c50732dab03efeb37472b08a3f32
entry is now input
moduleName is now output.name
format is now output.format
...

npm run command automatically uses local rollup cli and you don't need the global one.

This comment has been minimized.

@nazihahmed

nazihahmed Feb 1, 2018
Author Contributor

yes, I do use this, but the issue is not rollup, rollup works but throws a different error (It looks like your Babel configuration specifies a module transformer), so I added this file and it worked for me, anyways I removed this file for you to merge.
when will you publish the next version to npm? we are still using our own library.

@kt3k
Copy link
Member

@kt3k kt3k commented Feb 1, 2018

Thanks for finding out these! 👍

nazihahmed added 2 commits Feb 1, 2018
@codecov-io
Copy link

@codecov-io codecov-io commented Feb 1, 2018

Codecov Report

Merging #2273 into master will increase coverage by 1.51%.
The diff coverage is 37.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2273      +/-   ##
==========================================
+ Coverage   73.88%   75.39%   +1.51%     
==========================================
  Files          51       51              
  Lines        4185     4186       +1     
==========================================
+ Hits         3092     3156      +64     
+ Misses       1093     1030      -63
Impacted Files Coverage Δ
src/api.chart.js 12% <0%> (-0.5%) ⬇️
src/core.js 89.37% <60%> (+0.17%) ⬆️
src/interaction.js 39.2% <0%> (+3.97%) ⬆️
src/shape.line.js 70.69% <0%> (+6.04%) ⬆️
src/api.focus.js 100% <0%> (+8.57%) ⬆️
src/shape.bar.js 100% <0%> (+9.72%) ⬆️
src/arc.js 83.12% <0%> (+13.58%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f0a586...8a0127e. Read the comment docs.

@kt3k
kt3k approved these changes Feb 1, 2018
@Mobiletainment
Copy link

@Mobiletainment Mobiletainment commented Feb 6, 2018

is there any update on this? Would love to see it go into master.

@nazihahmed
Copy link
Contributor Author

@nazihahmed nazihahmed commented Feb 7, 2018

@Mobiletainment you can use alooma-c3 while they release the new version, after they release it you simply change back to c3 in your package.json

@kt3k
Copy link
Member

@kt3k kt3k commented Feb 10, 2018

The root problem was that the attached function (resizeIfElementDisplayed) and the detached one (resizeFunction) were different and the attached one was leaked every time. This seems to have started at #2164. Thanks again for finding out this!

By the way $$.resizeFunction.remove() doesn't seem removing internal resize functions, because it removes the only given function (see

c3/src/core.js

Lines 988 to 995 in 7e5c20c

callResizeFunctions.remove = function (f) {
for (var i = 0; i < resizeFunctions.length; i++) {
if (resizeFunctions[i] === f) {
resizeFunctions.splice(i, 1);
break;
}
}
};
). We follow up this on another PR.

@kt3k kt3k merged commit 45ae244 into c3js:master Feb 10, 2018
2 checks passed
2 checks passed
ci/circleci Your tests passed on CircleCI!
Details
codecov/project 75.39% (+1.51%) compared to 9f0a586
Details
@nazihahmed
Copy link
Contributor Author

@nazihahmed nazihahmed commented Feb 11, 2018

@kt3k great, this is the problem that I solved, hopefully not introducing another one..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.