If xml::tclparser::parse is called with the final set to 1 (the default), then the '-statevariable' option is not passed into sgml::parseEvent.
As a result sgml::parseEvent will create its own -statevariable called ParseEvent[num]. These variables are not properly cleaned up when xml::tclparser::delete is called, which can build up cruft with repeated parsings.
Here's the script I used to test this:
package require xml
proc parseXml {str_to_parse} {
set xml_parser [::xml::parser]
$xml_parser parse $str_to_parse
$xml_parser free
unset xml_parser
}
set xmlData "<?xml version='1.0'?><response><action id='DoStuff'><state><current>OFF</current><next>ON</next></state></action></response>"
while 1 {
parseXml $xmlData
set sgmlVars [info vars ::sgml::*]
set numSgmlVars [llength $sgmlVars]
puts "sgml vars ($numSgmlVars): $sgmlVars\n"
}