You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/03/20 17:47:33 UTC

[GitHub] [incubator-mxnet] yuxihu opened a new pull request #14480: Fix memory leak for size-zero ndarray

yuxihu opened a new pull request #14480: Fix memory leak for size-zero ndarray
URL: https://github.com/apache/incubator-mxnet/pull/14480
 
 
   The original fix #14365 caused test flakiness (See #14477 for more details).
   
   For size-zero ndarray (e.g. mx.nd.array([]), mx.nd.ones(0)), the storage handle size is 0. When allocating memory for such ndarray, we round the size (0) to the page size (4096 bytes) in [GPUPooledStorageManager](https://github.com/apache/incubator-mxnet/blob/master/src/storage/pooled_storage_manager.h#L105), and we perform aligned allocation (16/64 bytes) on [CPU](https://github.com/apache/incubator-mxnet/blob/master/src/storage/cpu_device_storage.h#L73). However, we currently only free handle which size is larger than 0, which leads to memory leak.
   
   Instead of checking size > 0, we check if the data pointer (dptr) in storage handle is nullptr to decide if we need to free memory. If the storage handle has been allocated memory, the dptr cannot be nullptr and we need to free it.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services