-
-
Notifications
You must be signed in to change notification settings - Fork 221
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 a couple of cpu profile memory leaks #218
Conversation
Codecov Report
@@ Coverage Diff @@
## master #218 +/- ##
=======================================
Coverage 95.59% 95.59%
=======================================
Files 16 16
Lines 545 545
=======================================
Hits 521 521
Misses 15 15
Partials 9 9 Continue to review full report at Codecov.
|
v8go.cc
Outdated
@@ -286,6 +286,7 @@ void CPUProfileNodeDelete(CPUProfileNode* node) { | |||
CPUProfileNodeDelete(node->children[i]); | |||
} | |||
|
|||
delete node->children; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing to
delete node->children; | |
delete[] node->children; |
to avoid a Mismatched free() / delete / delete []
error
be55804
to
9af31fd
Compare
I reran valgrind with |
I wonder if it would make sense to document this in a DEVELOPMENT type doc and/or run valgrind in our ci flow against the whole test suite. Not everyone might have it installed on their machines and it would be a helpful ci check on PRs |
Problem
I tried using valgrind to check for leaks in v8go and found some in the cpu profiling code that can be reproduced using
go test -c && valgrind --leak-check=full --show-leak-kinds=definite --track-origins=yes ./v8go.test -test.run=TestCPUProfile
(run on linux with valgrind already installed)Here are the unique leaks that valgrind detected
Solution
I added the missing
delete
for the C++ allocated memory andfree
for themalloc
allocated memory.