title: Out of Memory exception while running multithreaded code
body: <p>I am working on a project in which I will be having different Bundles. Let's take an example, Suppose I have 5 Bundles and each of those bundles will have a method name <code>process</code>.</p>
  
  <p>Now currently, I am calling the <code>process</code> method of all those 5 bundles in parallel using multithread code below.</p>
  
  <p>But somehow, everytime when I am running the below multithread code, it always give me out of memory exception. But if I am running it sequentially meaning, calling process method one by one, then it don't give me any Out Of memory exception.</p>
  
  <p>Below is the code-</p>
  
  <pre><code>public void callBundles(final Map&lt;String, Object&gt; eventData) {
  
      // Three threads: one thread for the database writer, two threads for the plugin processors
      final ExecutorService executor = Executors.newFixedThreadPool(3);
  
      final Map&lt;String, String&gt; outputs = (Map&lt;String, String&gt;)eventData.get(Constants.EVENT_HOLDER);
  
      for (final BundleRegistration.BundlesHolderEntry entry : BundleRegistration.getInstance()) {
          executor.submit(new Runnable () {
              public void run() {
                  try {
                      final Map&lt;String, String&gt; response = entry.getPlugin().process(outputs);
  
                      //process the response and update database.
                      System.out.println(response);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }               
              }
          });
      }
  }
  </code></pre>
  
  <p>Below is the exception, I am getting whenever I am running above Multithreaded code.</p>
  
  <pre><code>JVMDUMP006I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" - please wait.
  JVMDUMP032I JVM requested Heap dump using 'S:\GitViews\Stream\goldseye\heapdump.20130904.175256.12608.0001.phd' in response to an event
  JVMDUMP010I Heap dump written to S:\GitViews\Stream\goldseye\heapdump.20130904.175256.12608.0001.phd
  JVMDUMP032I JVM requested Java dump using 'S:\GitViews\Stream\goldseye\javacore.20130904.175256.12608.0002.txt' in response to an event
  UTE430: can't allocate buffer
  UTE437: Unable to load formatStrings for j9mm
  JVMDUMP010I Java dump written to S:\GitViews\Stream\goldseye\javacore.20130904.175256.12608.0002.txt
  JVMDUMP032I JVM requested Snap dump using 'S:\GitViews\Stream\goldseye\Snap.20130904.175256.12608.0003.trc' in response to an event
  UTE001: Error starting trace thread for "Snap Dump Thread": -1
  JVMDUMP010I Snap dump written to S:\GitViews\Stream\goldseye\Snap.20130904.175256.12608.0003.trc
  JVMDUMP013I Processed dump event "systhrow", detail "java/lang/OutOfMemoryError".
  ERROR: Bundle BullseyeModellingFramework [1] EventDispatcher: Error during dispatch. (java.lang.OutOfMemoryError: Failed to create a thread: retVal -1073741830, errno 12)
  java.lang.OutOfMemoryError: Failed to create a thread: retVal -1073741830, errno 12
  
  JVMDUMP006I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" - please wait.
  JVMDUMP032I JVM requested Heap dump using 'S:\GitViews\Stream\goldseye\heapdump.20130904.175302.12608.0004.phd' in response to an event
  JVMDUMP010I Heap dump written to S:\GitViews\Stream\goldseye\heapdump.20130904.175302.12608.0004.phd
  JVMDUMP032I JVM requested Java dump using 'S:\GitViews\Stream\goldseye\javacore.20130904.175302.12608.0005.txt' in response to an event
  </code></pre>
  
  <p>I am using <code>JDK1.6.0_26</code> as the installed JRE's in my eclipse.</p>