andrewfayres commented on a change in pull request #14372: Memory fixes. 
Resolves #10867, and resolves #14080
URL: https://github.com/apache/incubator-mxnet/pull/14372#discussion_r269790876
 
 

 ##########
 File path: 
scala-package/core/src/main/scala/org/apache/mxnet/ResourceScope.scala
 ##########
 @@ -48,8 +48,10 @@ class ResourceScope extends AutoCloseable {
     */
   override def close(): Unit = {
     ResourceScope.removeFromThreadLocal(this)
-    resourceQ.foreach(resource => if (resource != null) 
resource.dispose(false) )
-    resourceQ.clear()
+    if (!ResourceScope.threadLocalScopes.get().contains(this)) {
 
 Review comment:
   Discussed offline so resolving.
   
   Summary of offline discussion:
   The private UsingIfExists method adds an existing scope onto the stack. We 
don't want to clear that scope when it's removed from the stack and this if 
should make sure we don't.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to