Skip to content

Memory leak fix#2273

Merged
kt3k merged 7 commits intomasterfrom
unknown repository
Feb 10, 2018
Merged

Memory leak fix#2273
kt3k merged 7 commits intomasterfrom
unknown repository

Conversation

@maxkna111
Copy link
Copy Markdown
Contributor

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

@maxkna111
Copy link
Copy Markdown
Contributor Author

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
Comment thread package.json
"node-sass": "^4.5.3",
"node-static": "^0.7.9",
"nodemon": "^1.11.0",
"rollup": "^0.55.0",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment thread .babelrc Outdated
@@ -0,0 +1,13 @@
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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
Copy Markdown
Member

kt3k commented Feb 1, 2018

Thanks for finding out these! 👍

@codecov-io
Copy link
Copy Markdown

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.

@Mobiletainment
Copy link
Copy Markdown

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

@maxkna111
Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Member

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
@kt3k
Copy link
Copy Markdown
Member

kt3k commented Feb 10, 2018

@maxkna111
Copy link
Copy Markdown
Contributor Author

@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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repeatedly calling c3.generate leaks memory in 0.4.9

4 participants