Skip to content

Commit cdb8f43

Browse files
committed
Fixed memory leak in move assignment operator.
1 parent 967577b commit cdb8f43

File tree

3 files changed

+52
-21
lines changed

3 files changed

+52
-21
lines changed

scripts/valgrind.supp

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
# OpenMP suppressions
161161
################################################################################
162162
{
163-
libomp
163+
libomp leak
164164
Memcheck:Leak
165165
...
166166
obj:/*/libomp.so*
@@ -177,40 +177,38 @@
177177
}
178178

179179
{
180-
gomp realloc
180+
gomp leak
181181
Memcheck:Leak
182-
fun:realloc
183-
fun:gomp_realloc
182+
...
183+
obj:/*/libgomp.so*
184184
...
185185
}
186186

187-
188-
# For blueos
189187
{
190-
libxlsmp
188+
libxlsmp leak
191189
Memcheck:Leak
192190
...
193191
obj:/*/libxlsmp.so*
194192
...
195193
}
196194

195+
################################################################################
196+
# CUDA suppressions
197+
################################################################################
197198
{
198199
libcuda malloc
199200
Memcheck:Leak
200201
fun:malloc
201-
obj:/*/valgrind/*
202+
...
202203
obj:/*/libcuda.so*
203204
...
204205
}
205206

206-
################################################################################
207-
# CUDA suppressions
208-
################################################################################
209207
{
210208
libcuda realloc
211209
Memcheck:Leak
212210
fun:realloc
213-
obj:/*/valgrind/*
211+
...
214212
obj:/*/libcuda.so*
215213
...
216214
}
@@ -219,35 +217,43 @@
219217
libcuda calloc
220218
Memcheck:Leak
221219
fun:calloc
220+
...
222221
obj:/*/libcuda.so*
223222
...
224223
}
225224

226225
{
227-
libcuda strdup malloc
226+
cudaGetSymbolAddress leak
228227
Memcheck:Leak
229-
fun:malloc
230-
fun:strdup
231-
obj:/*/libcuda.so*
228+
...
229+
fun:cudaGetSymbolAddress
232230
...
233231
}
234232

235233
{
236-
cudaGetSymbolAddress
234+
cudaGetDeviceCount leak
237235
Memcheck:Leak
238236
...
239-
fun:cudaGetSymbolAddress
237+
fun:cudaGetDeviceCount
240238
...
241239
}
242240

243241
{
244-
cudaGetDeviceCount
245-
Memcheck:Leak
242+
cudaGetDeviceCount conditional
243+
Memcheck:Cond
246244
...
247245
fun:cudaGetDeviceCount
248246
...
249247
}
250248

249+
{
250+
cudaStreamCreate leak
251+
Memcheck:Leak
252+
...
253+
fun:cudaStreamCreate
254+
...
255+
}
256+
251257
{
252258
__cudaPushCallConfiguration malloc
253259
Memcheck:Leak
@@ -257,6 +263,24 @@
257263
...
258264
}
259265

266+
{
267+
cudaGetDeviceCount Value8
268+
Memcheck:Value8
269+
...
270+
fun:cudaGetDeviceCount
271+
...
272+
}
273+
274+
{
275+
cudaMalloc reachable leak
276+
Memcheck:Leak
277+
match-leak-kinds: reachable
278+
fun:malloc
279+
...
280+
fun:cudaMalloc
281+
...
282+
}
283+
260284
################################################################################
261285
# libpsm2 suppressions
262286
################################################################################

src/Array.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ class Array : public ArrayView< T,
192192
LVARRAY_HOST_DEVICE
193193
Array & operator=( Array && rhs )
194194
{
195+
bufferManipulation::free( this->m_dataBuffer, this->size() );
196+
195197
ParentClass::operator=( std::move( rhs ) );
196198

197199
for( int i = 0; i < NDIM; ++i )

src/SortedArray.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ class SortedArray : protected SortedArrayView< T, INDEX_TYPE, BUFFER_TYPE >
111111
* @return *this.
112112
*/
113113
inline
114-
SortedArray & operator=( SortedArray && src ) = default;
114+
SortedArray & operator=( SortedArray && src )
115+
{
116+
bufferManipulation::free( this->m_values, size() );
117+
ParentClass::operator=( std::move( src ) );
118+
return *this;
119+
}
115120

116121
///@}
117122

0 commit comments

Comments
 (0)