title: Profiling a GWT application for finding Memory leak
body: <p>We have a GWT based application deployed on Tomcat. Every other day the application crashes with OutOfMemoryException. So i have started taking the heap dump of the application when it is close to using maximum allocated memory.</p>
  
  <p>The behavior of application is the following,</p>
  
  <ol>
  <li>User Logs in to the application</li>
  <li>Enters input to the application which is to be ananlyzed on the server using a cluster setup.</li>
  <li>The client polls the server every 15 seconds for the status of the job and updates the UI controls. The polling is done using requestfactory calls pulling some data from server.</li>
  <li>If the job is done , we display the results to the user using a flextable. There can be around 1000 rows with 6 columns.</li>
  </ol>
  
  <p>Heap Dump,</p>
  
  <p>We took a heap dump of the tomcat process using jmap to see what is holding on to the memory. The following pictures are taken using Eclipse Memory Analyzer with the heap dump.</p>
  
  <p><img src="https://i.stack.imgur.com/Vo1mF.jpg" alt="Overview of the heap dump"></p>
  
  <p><img src="https://i.stack.imgur.com/x6zWD.jpg" alt="Domiator Tree"></p>
  
  <p><img src="https://i.stack.imgur.com/uwhw5.jpg" alt="Dominator Tree"></p>
  
  <p><img src="https://i.stack.imgur.com/pSEHP.jpg" alt="Expanded dominator tree"></p>
  
  <p>We can see that there are lots of hashmap entries being kept in the heap with retained size of 25k and there are about 6 million of them. </p>
  
  <p>Questions:</p>
  
  <ol>
  <li>com.google.gwt.core.client.impl.WeakMapping shows shallow heap of 16
  bytes but the retained heap is almost all the memory we allocated
  for the application.</li>
  <li>Is it because we are polling the server every 15 seconds and retrieving data which is somehow being referenced and not GCed. </li>
  <li>How do we unreference these hashmap.</li>
  <li>Is it anything completely different from the scenarior mentioned here.</li>
  </ol>
  
  <p>We have so far used jconsole, jprofiler, MAT, jhat in analyzing the application. And we have no clue where the issue. </p>
  
  <p>Appreciate your help.</p>