Have a look at this code:
https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/optimizer/AdaDelta.scala
There they have the same problem and use disposeDepsExcept to release resources.
Jörn
On Tue, Oct 17, 2017 at 4:18 PM, TongKe Xue
Quoting:
https://github.com/apache/incubator-mxnet/blob/master/scala-package/core/src/main/scala/ml/dmlc/mxnet/NDArray.scala#L545-L546
* WARNING: it is your responsibility to clear this object through dispose().
* NEVER rely on the GC strategy
Is there a way to say "dispose all ndarrays of this