For performance enhancement reasons, the unmarshal()method does not unmarshal the entire message to the leaf element and subelement level. Instead, this method does the following:
Unmarshals the incoming message at the segment and composite level. In other words, the OTD checks for all relevant segments and composites and reports any missing or extra segments or composites.
Reports excess trailing delimiter for elements and composites.
This behavior is also referred to as “parse on demand,” meaning that elements within a segment or composite are not unmarshaled until an element in that segment or composite is accessed by a getxxx() method invoked in a Collaboration or during marshaling. The OTD may assign unmarshaled segments and composites to a pool that is ready to be freed from memory by the Java Virtual Machine software. Once these segments or composites are freed from memory, they become unparsed. If the element within the segment or composite is accessed again, the OTD reparses the segment or composite.
By default, HIPAA OTDs set no limit of parsed segments or composites held in memory. You can specify a limit for parsed and freed segments or composites by using the following methods at the OTD root levels:
setMaxParsedSegsComsNum() method ( see setMaxParsedSegsComsNum)
setMaxFreedSegsComsNum() method (see setMaxFreedSegsComsNum)
You can use these methods to set and control the runtime memory use of the unmarshaling process.