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/27 21:58:55 UTC

[GitHub] [incubator-mxnet] andrewfayres commented on a change in pull request #14372: Memory fixes. Resolves #10867, and resolves #14080

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


With regards,
Apache Git Services