Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XML Parsers to use object pooling  RSS feed

 
Jes Sie
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear people,
I'm a newbie in this forum.
Somebody suggested that the XML parser used in our project should be 'object pooled'. I understand object pooling. In fact, I've used commons-pooling by Jakarta before. But, I don't quite understand how a parser instantiation would cause memmory consumption/performance issue. Wouldn't it best be in some kinda Singleton?
Any hints would be appreciated. Thanks.
 
Jes Sie
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hellou, anyone out there please comment....
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!