Killing Moon Software Community Zone
director

« Director Index

netLingo
Quit Projector
XML Parser
 

XML Parser Bugs

Update: Macromedia has now released a fix for the second part of this bug as part of their 10.1 update to MX2004.

Version 10.1 Release Notes

There has for some time been a known bug in the XML parser that causes a memory leak whenever parseString is called. This has been known since version 8.5 and was not fixed in MX (both use the same version of the XML parser Xtra). This bug was previously documented as affecting only the Mac version, but tests have since verified that it also affects the Windows version.

The aforementioned bug has been fixed as of Director MX2004.

However, it turns out that there is another bug that also causes a memory leak. This occurs whenever a node is referenced in the parsed XML document object. The makeList method is safe, so this can be used as a workaround in MX2004.

Here is an example of some XML parsing code that will always cause a memory leak:

  vXML = member( "xml" ).text -- Some valid XML to parse
  vParser = xtra( "xmlParser" ).new() -- Instatiate parser
  vParser.parseString( vXML ) -- Causes memory leak in D8.5 and MX
  vNodeName = vParser.child[1].name -- Causes memory leak in all versions

Here is an example of some XML parsing code that might cause a memory leak under version 8.5 or MX, but is safe in MX2004:

  -- As before...
  vXML = member( "xml" ).text
  vParser = xtra( "xmlParser" ).new()
  vParser.parseString( vXML ) -- Causes memory leak in D8.5 and MX

  -- Safe in MX2004...
  vXML = vParse.makeList() -- Always safe
  vNodeName = vXML[1].getPropAt( 2 ) -- The name of the first node

Demostrating the Bugs

To verify these bugs for yourself, you will need my demonstration movie:

Verified results are listed in the following table:

Test Description   8.5/MX   MX2004 - 10.0   MX2004 - 10.1
Win Mac Win Mac Win Mac
1 ParseString FAIL FAIL Pass Pass Pass Pass
2(a) Node, parse once FAIL FAIL FAIL FAIL Pass Pass
2(b) Node, parse many FAIL FAIL FAIL FAIL Pass Pass
3(a) MakeList, parse once Pass Pass? Pass Pass? Pass Pass
3(b) MakeList, parse many FAIL FAIL Pass Pass? Pass Pass

  • Thanks to Alex Zavatone, Petro Bochan, Lee C, Rob Romanek and Tony Bray for verifying and adding to my own test results.
  • Results marked ? are believed correct, but test results submitted were incomplete, so you may want to verify these tests yourself.
  • Please contact me if you have results that differ from those shown in the table.

Conclusions

The conclusions that can be drawn from these results are:

  1. It is not safe to use the XML parser at all in Director 8.5 or MX, unless the total number of documents to be parsed is very small and is not dependent on user interaction (i.e., the number will not increase because of something the user does).

  2. It is not safe to access nodes of the parsed XML document object in any version of Director prior 10.1.

  3. It is safe to call makeList as many times as required in any version of Director. Since it is safe to parse documents in MX2004, the safest method in that version is to use MakeList and traverse the resulting list rather than traverse the XML nodes directly.

  4. All methods are completely safe with the 10.1 update, however, if delivering for Shockwave and you intend to traverse XML through the parser object interface, then you must you must ensure that your end-users have the 10.1 update installed rather than just 10.0.

Article Information

Published: 2004.08.04
Updated: 2005.02.12
Author: Robert Tweed

 

 
Copyright © Robert Tweed, 2001-2005