title: How to reduce Spring memory footprint
body: <p>I would like to ask you HOW (or IF) is possible to reduce Spring framework's RAM footprint.</p>
  
  <p>I created a simple helloworld app for demonstrating the issue. There are only two classes and context.xml file:</p>
  
  <ul>
  <li><code>Main</code> - class with main method</li>
  <li><code>Test</code> - class used for simulating some "work" (printig Hello in endless loop)</li>
  </ul>
  
  <p><code>context.xml</code> contains only this:</p>
  
  <pre><code>&lt;context:component-scan base-package="mypackage" /&gt;
  </code></pre>
  
  <p>Test class contains only metod called <code>init</code>, called after construction:</p>
  
  <pre><code>@Component
  public class Test{
  
      @PostConstruct
      public void init() {
          Thread t = new Thread(new Runnable() {
  
              @Override
              public void run() {
                  try {
                      while (true) {
                          System.out.println("Hello " + Thread.currentThread().getName());
                          Thread.sleep(500);
                      }
                  } catch (InterruptedException ex) {
                      ex.printStackTrace();
                  }
              }
          });
          t.start();
      } 
  }
  </code></pre>
  
  <p>I prepared two scenarios and in both of them <code>main</code> method contains only one line.</p>
  
  <p>In first scenario main method does this: <code>(new Test()).init();</code>
  App works without Spring and consumes only aprox. 8MB of RAM.</p>
  
  <p>In second scenario main method contains following: <code>new ClassPathXmlApplicationContext(new String[]{"spring/context.xml"});</code>
  So the  app is initialized throug Spring container and consumes aprox. 45MB of RAM !</p>
  
  <p>Is there any way how to reduce (in best case completely get rid of) this extra memory ? So far I wasn't able to find any fitting solution.</p>
  
  <p>I don't mind if there is the extra memory consumption on startup - this is perfectly fine, but after that, I need our app to reduce it.</p>
  
  <p>(The story behind this question is a bit more complicated, but this is for me now the core problem.)</p>
  
  <p>Thank you</p>