title: High memory usage when resolving @Transactional
body: <p>I am profiling my webapp (using Spring + Hibernate) and have found out that in the point where a service method has to be resolved as transactional, I get huge amounts of memory being used.</p>
  
  <p>This is the call to the service method from the Controller:</p>
  
  <pre><code>User e = userService.getUser();
  </code></pre>
  
  <p>And this is the said method in the Service:</p>
  
  <pre><code>@Transactional(readOnly = true)
      public User getUser(Long id) throws GenericDataBaseException, InstanceNotFoundException {
          User e = userDao.findById(id);
          return e;
      }
  </code></pre>
  
  <p>By debugging my application, I put a breakpoint right in the method call (first code snippet), and another one on the first line of getUser(). Now only this injection and aspect resolving of the @Transactional annotation fires 30 mb of memory usage. Here's a screencap of VisualVM:</p>
  
  <p><img src="https://i.stack.imgur.com/ixpcb.png" alt="enter image description here"></p>
  
  <p>The bump you see was provoked by this call. Now if a single controller method has several calls to transactional service methods, this accumulates to bumps of around 100MB of memory usage. This can be Garbage Collected so it's not a memory leak, but I am curious as to what might be causing this issue, and whether it's normal behaviour. This only happens the first time a transactional method is called. Succesive calls cause almost no memory usage.</p>
  
  <p>EDIT: Here's a heap dump after the memory bump:
  <img src="https://i.stack.imgur.com/NrNqW.png" alt="enter image description here"></p>
  
  <p>EDIT2: Here's another screencap with a lot of memory being eaten by Finalizer objects from some ZipFileInflaterInputStream (which I don't use!)
  <img src="https://i.stack.imgur.com/yA9wz.png" alt="enter image description here"></p>