title: Java OutOfMemoryException unable to create new native thread
body: <p>I have a server written in jav running at 100MB of RAM or so on startup(info gotten from viewing the process explorer). However, when a client connects to it to transfer a big file, the RAM usage goes up until around 160MB or so and I got the error below. I have tried setting -Xmx128m, -Xmx256m, -Xmx512m, -Xmx1024m to no avail. What should I do to prevent this from happening. This only happens when a client tries to get a big file from the server</p>
  
  <pre><code>java.lang.OutOfMemoryError: unable to create new native thread
  java.lang.Thread.start0(Native Method)
  java.lang.Thread.start(Unknown Source)
  com.sun.jndi.ldap.Connection.&lt;init&gt;(Unknown Source)
  com.sun.jndi.ldap.LdapClient.&lt;init&gt;(Unknown Source)
  com.sun.jndi.ldap.LdapClient.getInstance(Unknown Source)
  com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
  com.sun.jndi.ldap.LdapCtx.&lt;init&gt;(Unknown Source)
  com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
  com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
  com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
  com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
  javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
  javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
  javax.naming.InitialContext.init(Unknown Source)
  javax.naming.ldap.InitialLdapContext.&lt;init&gt;(Unknown Source)
  </code></pre>