title: String creation in local method and heap memory
body: <p>I have a method in a class where I create a string like this:</p>
  
  <pre><code>private void log(HttpServletRequest request, HttpServletResponse response) {
      String result = "Following request " + request.getRequestURI() + " yielded " + response.getStatus();
      log.info(result);
  }
  </code></pre>
  
  <p>My question is, <code>result</code> string is generated millions of times. Does it have impact on heap memory?</p>
  
  <p>My current understanding is that each method has its own heap memory allocation. After method finishes executing, all local variables vanish from memory. </p>
  
  <p>My other understanding is that Strings are stored in global heap memory, and they get cleaned up on next Garbage collection cycle. </p>
  
  <p>Can someone please put some light on this I shall be thankful. </p>