Tuesday, January 12, 2010

Parsing the iTunes XML file yet again...

I've discovered that the major cause of the memory leak was using ITunesController.  Something I'd always suspected but I didn't really have any ideas for how to get around it.  Until I finally figured out how to get the track locations from the iTunes XML file.  It mainly has to do with the URLDecoder class.  But once you use the decoder class there are still some characters that the XML file has thrown in there that don't seem to be UTF-8.  So replace those characters and bam you've got track locations.  The other benefit is that the file is parsed by line, both good and bad.

The good...is that it's much faster just reading the xml file line by line.

The bad...if Apple changes the itunes xml file format or simply rearranges the lines.  I've got to go back and fix the parser.  But I don't think they will ever change it so I'm good there.

More updates to follow later.

Now that I can reliably parse locations from the iTunes XML file.  I now remove another component that requires the ITunesController and hence objects that can't be garbage collected.

Lastly, every time the add tracks operation was run a new playlist was added to iTunes....another memory leak generator.  So I've switched a simple text file that contains new tracks that have been added to iTunes.  The user can right click on the tray icon and select an option to open the text file and a button has also been added to the Add Tracks Panel.

No comments:

Post a Comment