stevedlawrence commented on a change in pull request #437:
URL: https://github.com/apache/incubator-daffodil/pull/437#discussion_r506448616



##########
File path: 
daffodil-core/src/test/scala/org/apache/daffodil/infoset/TestInfoset.scala
##########
@@ -74,12 +74,17 @@ object TestInfoset {
   }
 
   /**
-   * Returns the root element of the infoset, along with
-   * the schema compiler Root object for examining schema-compiler
-   * computations for unit testing them.
+   * Returns the root element of the infoset, along with the schema compiler
+   * Root object for examining schema-compiler computations for unit testing
+   * them. Because this assumes tests will be inspecting the internal infoset
+   * for correctness, it sets the releaseUnusedInfoset tunable to false so that
+   * the infoset elements are not freed
    */
   def testInfoset(testSchema: scala.xml.Elem, infosetAsXML: scala.xml.Elem): 
(DIElement, Root, DaffodilTunables) = {
-    val schemaCompiler = 
Compiler().withTunable("allowExternalPathExpressions", "true")
+    val schemaCompiler =
+      Compiler()
+        .withTunable("allowExternalPathExpressions", "true")
+        .withTunable("releaseUnneededInfoset", "false")

Review comment:
       It's actually kindof hard to write a test to make sure everything is 
getting cleaned up appropriately. At the end of unparsing, the DIDocument 
should have a single child, the root element. If that root element isn't used 
in an expression it should get set to null. So at the end of a parse, the 
DIDocument child(0) should be null if not used in an expression. But that only 
tests that we were able to free the root element. It's possible things were 
broken so that no a single other element was freed and the only thing actually 
freed was the root element. And since the root elemen was freed, there's no way 
to know if any of it's children were freed--we no longer have any access to it 
or it's children.
   
   Maybe the best way to ensure this is working correctly is to just develop 
tests that would fail with OutOfMemory errors if we weren't cleaning up infoset 
correctly. Those tests would likely be too large/take too long to keep in the 
Daffodil repo, but I believe @dfthompson is working on some tests that live in 
Owl's internal test infrastructure. Once those are done, we might want to find 
a place where those can be made public so others can test them.




----------------------------------------------------------------
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:
[email protected]


Reply via email to