Skip to content

Fix memory leak in test#18622

Merged
luotao1 merged 4 commits intoPaddlePaddle:developfrom
kbinias:kbinias/remove-gtest-main-memory-leak
Aug 2, 2019
Merged

Fix memory leak in test#18622
luotao1 merged 4 commits intoPaddlePaddle:developfrom
kbinias:kbinias/remove-gtest-main-memory-leak

Conversation

@kbinias
Copy link
Contributor

@kbinias kbinias commented Jul 12, 2019

This PR fixes the memory leak in the module that initiates all unit tests.

The fix is not critical because the system will deallocate the memory when exiting the function, but limits the number of errors in the AddressSanitizer report: ==56712==ERROR: LeakSanitizer: detected memory leaks

@kbinias kbinias requested a review from jczaja July 30, 2019 09:40
jczaja
jczaja previously approved these changes Jul 30, 2019
Copy link
Contributor

@jczaja jczaja left a comment

Choose a reason for hiding this comment

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

LGTM

}
env_string = env_string.substr(0, env_string.length() - 1);
new_argv.push_back(strdup(env_string.c_str()));
new_argv.push_back(const_cast<char*>(env_string.c_str()));
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not recommended to use const_cast, could you use another way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prepared other solution (without const_cast)

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1 luotao1 merged commit c2c876f into PaddlePaddle:develop Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants