6 Replies Latest reply on Sep 15, 2014 4:18 PM by weboctave

    jboss7, java.lang.OutOfMemoryError: unable to create new native thread

    varsha g Newbie

      I am using the jsp-servlet in my application. and deployed the war on jboss 7.0.2 server. i have servlet have code related to database and that is being called many time in sec (say 500 times).  but it is falling over for such many threads, jboss 7.0.2 will not able to handle this threads.

       

      I am using the 64 bit jvm.

      I have reduce the size of the thread stack with -Xss256k, this  not work for me.

      i did the configuration in jboss.conf

      wrapper.java.additional.10=-XX:ThreadStackSize=256k

      I need to handle the 2000 threads on jboss7.

       

      server (jboss7.0.2) throws an exception.

       

          java.lang.OutOfMemoryError: unable to create new native thread

           at java.lang.Thread.start0(Native Method)

           at java.lang.Thread.start(Unknown Source)

       

      Here is my servlet java.lang.OutOfMemoryError: unable to create new native thread

       

              public class Test extends HttpServlet {

          private static final long serialVersionUID = 1L;

       

          public Test() {

              super();

          }

       

          protected void doGet(HttpServletRequest request,

                    HttpServletResponse response) throws ServletException, IOException   {

              processRequest(request, response);

          }

       

          protected void doPost(HttpServletRequest request,

                  HttpServletResponse response) throws ServletException, IOException {

              processRequest(request, response);

          }

       

          public void processRequest(HttpServletRequest request,

                  HttpServletResponse response) {

              Logger log=LoggerFactory.getLogger(feedback.class);

       

                 /*   here is my code to insert the data in database. */

       

                      TestClass testobj = new TestClass();       

       

                      testobj.setparam("");

       

       

              smsmanager1.add(sms);

       

              smsmanager1 = null;

              sms = null;

       

       

          }

            }

       

      code fot add method

       

             public void add(T obj) {

                   SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

                   Session session=sessionFactory.openSession();

                   Transaction transaction = null;

                   try {

                           transaction = session.beginTransaction();

                           session.save(obj);

                           transaction.commit();

                           session.flush();

       

                   } catch (HibernateException e) {

                       if(transaction!=null){

                           transaction.rollback();}

                           e.printStackTrace();

                   } finally {

                       if(session!=null){

                           session.close();}

                           session = null;

                           transaction = null;

                   }

       

      i have tested for the blank servlet that has the only one console printing statement. it works fine but it not work for above servlet.

       

      am i on the right track here ?

      how the server will handle the such servlet for above 500-800 threads ?