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_r269787536
 
 

 ##########
 File path: 
scala-package/core/src/test/scala/org/apache/mxnet/ResourceScopeSuite.scala
 ##########
 @@ -101,6 +101,38 @@ class ResourceScopeSuite extends FunSuite with 
BeforeAndAfterAll with Matchers {
     assert(a.isDisposed == true, "returned object should be disposed in the 
outer scope")
   }
 
+  /**
+    * Tests passing a scope to using and creating new resources within.
+    */
+  test("test moving scope of native resource to scope of another") {
+    var a: TestNativeResource = null
+    var b: TestNativeResource = null
+    var c: TestNativeResource = null
+    var d: TestNativeResource = null
+
+    ResourceScope.using() {
+      a = new TestNativeResource()
+      ResourceScope.using() {
+        b = new TestNativeResource()
+        ResourceScope.usingIfScopeExists(a.scope) {
+          c = new TestNativeResource()
+          ResourceScope.using() {
+            d = new TestNativeResource()
+          }
+          assert(d.isDisposed == true)
+        }
+        assert(b.isDisposed == false)
+        assert(c.isDisposed == false)
 
 Review comment:
   Good suggestions. I've added 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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to