julman99 / gson-fire

A java library that adds some very useful features to Gson, like Date serializing to unix timestamp or RFC3339, method (getters) serialization, pre/post processors and many others. Check out the documentation to learn how to use it!
http://gsonfire.io
Other
226 stars 36 forks source link

Reuse Exclusion Strategies #31

Closed Frotty closed 6 years ago

Frotty commented 7 years ago

Hi, is there a way to make classes that extend ExclusionByValueStrategy singleton? I profiled my app and the ExcludeLogic Class apparently gets created every time an object is being serialized, when there is really just one instance required.

julman99 commented 7 years ago

That is a good catch! I wonder if I should cache the instance forever, or put it in a WeakReference and use it while it is available.

Frotty commented 7 years ago

Thanks for the fix! When will you release the next version?

julman99 commented 7 years ago

Mid oct at the latest

Just for curiosity, was this causing performance issues for you? I assume it was the reflection invocation of newInstance in the class

Frotty commented 7 years ago

Yes, gson already creates many classes. With fire and all my stuff enabled it got up to millions of instances, Many of those were the exclusion strategies - something I couldn't really fix. Is there a snapshot i can use to test if it's fixed?

julman99 commented 7 years ago

No snapshot, but you can clone this repo, checkout branch v1.8.0_exclude-by-value-singleton, change the pom version to whatever you want, do mvn install and then use that version in your code. Maven should resolve the dependency locally

Frotty commented 7 years ago

Still waiting on that 1.7.3 release 🌴

julman99 commented 7 years ago

It's coming out tomorrow

Frotty commented 7 years ago

julman99 commented 4 days ago It's coming out tomorrow

😢

julman99 commented 7 years ago

I am terribly sorry for the delay. Just released version 1.8.0 and it contains the fix for this issue. Can you confirm you see an improvement?

Frotty commented 7 years ago

Hi I think it's fixed but I can't test it right now because my profiler license expired.

Frotty commented 6 years ago

Thanks again. I forgot to close.