inde...@gmail.com
unread,Oct 20, 2008, 2:26:44 PM10/20/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to google-gson
Yes, Gson is designed to be stateless from the point of view of the
object that it is called upon. So, it is best to just create Gson
instance once, and then reuse it everywhere.
Creating Gson is a somewhat expensive operation since it registers all
the default serializers, deserializers and instance creators. We have
tried to optimize that path by storing the default list as a static
final constant but still it is best to reuse the same instance of Gson
wherever you can. That will also give you the benefits of any JVM
hotspot optimizations that may happen because of the reused instance.
We typically use Guice to inject Gson once, and use that everywhere.
Inder