Skip to content

Conversation

FrostML
Copy link
Contributor

@FrostML FrostML commented Jan 13, 2020

In api.cc, malloc/free are used for initializing PaddleBuf while in paddle_api.h, new/delete are involved.
Since the valgrind will regard this inconsistency as memory leaking, this PR tries to fix this.

@FrostML FrostML requested a review from fc500110 January 13, 2020 11:39
Copy link
Contributor

@fc500110 fc500110 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -103,7 +103,7 @@ void PaddleBuf::Reset(void *data, size_t length) {
void PaddleBuf::Free() {
if (memory_owned_ && data_) {
PADDLE_ENFORCE_GT(length_, 0UL);
free(static_cast<char *>(data_));
delete static_cast<char *>(data_);
Copy link
Contributor

Choose a reason for hiding this comment

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

delete[]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks.

@FrostML FrostML merged commit 07afc29 into PaddlePaddle:develop Jan 14, 2020
@FrostML FrostML changed the title Make PaddleBuf's malloc consistent with paddle_api Make PaddleBuf's malloc consistent with paddle_api.h Jan 19, 2020
@FrostML FrostML changed the title Make PaddleBuf's malloc consistent with paddle_api.h Make PaddleBuf's malloc consistent with paddle_api\.h Jan 19, 2020
@FrostML FrostML changed the title Make PaddleBuf's malloc consistent with paddle_api\.h Make PaddleBuf's malloc consistent with paddle_api.h Jan 19, 2020
@FrostML FrostML deleted the free branch June 24, 2020 06:17
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.

2 participants