The problem with a singleton here is if you ever have more than one
thread trying to use the parser. A single parser really can't be used this way - so you'd need either a new parser for each thread, or an object pool. (Or you can use synchronization to ensure that only one thread uses the parser at a time - but that's slower.) If you're doing a
lot of parsing, and/or if the parsers are fairly large, complex objects (which they often are) then the object pool may be best in the long run. As usual though, it's best if you perform some profiling first to see if parser instantiation and GC is really a big contributor to current memory/performance problems (if there are any). If it ain't broke, don't fix it.
[ December 05, 2002: Message edited by: Jim Yingst ]