Killing Moon Software Community Zone
director

« Director Index
Bugs Index

netLingo
Quit Projector
XML Parser
 

XML Parser Bugs

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

The following movie demonstrates all of these bugs using a number of different tests. Download the .dir file and create a projector to test on your system. Please contact me if you have results that differ from those shown in the results table below.

Verified results are listed in the following table:

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

* Thanks to Alex Zavatone and Petro Bochan for verifying and adding to my own test results.

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 current version of Director.

  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, it is safe to use the XML parser in this version provided that the XML tree is traversed only via the list returned by the makeList method. The alternative interface of the XML parser object must be avoided completely.

Article Information

Published: 2004.08.04
Updated: 2002.08.04
Author: Robert Tweed

 

 
Copyright © Killing Moon Ltd., 2001-2004