For performance enhancement reasons, the unmarshal() method does not unmarshal the entire message. Instead, it 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 trailing delimiter for elements and composites.
This 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 in the Collaboration using a getxxx() method. The OTD may assigned unmarshaled segments and composites to a pool that is ready to be freed from memory by the Java Virtual Machine (JVM). Once these segments or composites are freed from memory, they become unparsed. If the element within segment or composite is accessed again, the OTD reparses the segment or composite.
By default, UN/EDIFACT OTDs set no limit of parsed segments or composites held in memory. You can specify a limit for parsed and freed segments or composited by using the following methods at the OTD root levels:
setMaxParsedSegsComsNum() method (setMaxParsedSegsComsNum
setMaxFreedSegsComsNum() method (setMaxFreedSegsComsNum)
You can use these methods to set and control the runtime memory use of the unmarshaling process.