title: Best way to cache/reuse json object
body: <p>Recently, we have issues with some of our production JVMs which is going for GC very frequently and taking long gc pause as well. After looking into the heap dump it seems a new class introduced in recent build storing large number of product data in json object causing this.</p>
  
  <p>This class basically gets the data from multiple sources and build the json object based on that. <strong>We can see these json objects are getting saved as char[] in heap space which is taking almost 25% of space. The problem is this class creating json object every time whenever method is getting called. So, for same product it's creating multiple json objects and filling up heap space quickly.</strong></p>
  
  <p><a href="https://i.stack.imgur.com/FfImt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FfImt.png" alt="enter image description here"></a></p>
  
  <p>We may need to use some type of caching but there are large number of products in site.Any suggestion how we can handle this issue in a better way?</p>