andrewfayres commented on a change in pull request #11204: Scala inference
memory leak fix
URL: https://github.com/apache/incubator-mxnet/pull/11204#discussion_r194492750
##########
File path: scala-package/core/src/main/scala/org/apache/mxnet/FeedForward.scala
##########
@@ -230,8 +230,11 @@ class FeedForward private(
val padded = batch.pad
val realSize = batchSize - padded
for ((list, nd) <- outputs zip predExec.outputs) {
- list += nd.slice(0, realSize).copy()
+ val ndSliced = nd.slice(0, realSize)
+ list += ndSliced.copy()
+ ndSliced.dispose()
Review comment:
If we're getting an exception here something has gone very wrong. Most
likely the problem would be memory access/allocation and I'm not confident
dispose would work correctly under those conditions.
I'll make the change anyway because although I think it's unlikely to ever
help it definitely won't hurt and is a good practice to follow.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services