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/14 00:33:26 UTC
[GitHub] [incubator-mxnet] eric-haibin-lin commented on a change in pull
request #14365: Fix memory leak for size-zero ndarray
eric-haibin-lin commented on a change in pull request #14365: Fix memory leak for size-zero ndarray
URL: https://github.com/apache/incubator-mxnet/pull/14365#discussion_r265383417
##########
File path: include/mxnet/ndarray.h
##########
@@ -1055,9 +1054,12 @@ class NDArray {
}
size_t aux_bytes = shape.Size() * mshadow::mshadow_sizeof(aux_types[i]);
if (aux_handles[i].size < aux_bytes) {
- // free storage if necessary and alloc again
- if (aux_handles[i].size > 0) Storage::Get()->Free(aux_handles[i]);
- // init aux storage
+ // set the context for aux handle to make sure we free it to the right device.
+ if (aux_handles[i].ctx.dev_type != ctx.dev_type) {
Review comment:
This usually do not happen. Have you observed such mismatch? Would it be more appropriate to add CHECK_EQ instead of modifying the ctx?
----------------------------------------------------------------
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