Skip to content

Commit 0fec946

Browse files
committed
fix some bugs introduced by unfreed memory
1 parent f43b71b commit 0fec946

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

paddle/fluid/operators/gather_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ TEST(Gather, GatherData) {
4343
auto* cpu_place = new paddle::platform::CPUPlace();
4444
paddle::platform::CPUDeviceContext ctx(*cpu_place);
4545
paddle::operators::CPUGather<int>(ctx, *src, *index, output);
46-
46+
delete cpu_place;
47+
cpu_place = NULL;
4748
for (int i = 0; i < 4; ++i) EXPECT_EQ(p_output[i], i + 4);
4849
for (int i = 4; i < 8; ++i) EXPECT_EQ(p_output[i], i - 4);
4950

paddle/fluid/operators/math/math_function_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ TEST(math_function, gemm_trans_clbas) {
7777
paddle::platform::CPUDeviceContext context(*cpu_place);
7878
GetBlas<float>(context).GEMM(false, true, m, n, k, 1, input1_ptr, 3,
7979
input2_ptr + 3, 3, 1, input3_ptr + 1, 4);
80+
delete cpu_place;
81+
cpu_place = NULL;
8082

8183
EXPECT_EQ(input3_ptr[0], 0);
8284
EXPECT_EQ(input3_ptr[1], 24);

paddle/fluid/platform/device_tracer.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ void CUPTIAPI bufferRequested(uint8_t **buffer, size_t *size,
130130
uint8_t *buf = reinterpret_cast<uint8_t *>(malloc(kBufSize + kAlignSize));
131131
*size = kBufSize;
132132
*buffer = ALIGN_BUFFER(buf, kAlignSize);
133+
free(buf);
134+
buf = NULL;
133135
*maxNumRecords = 0;
134136
}
135137

0 commit comments

Comments
 (0)