6 Replies Latest reply: May 8, 2011 12:18 PM by 833574 RSS

    Too many parked threads. Any memory impact ?

    833574
      We have Java web application running on Teiid framework within JBoss. Teiid talks to datasources and the application uses concurrency library to create an internal thread pool for Teiid.
      When I analyzed thread dumps from recent OOMs, I noticed that too many of Teiid pool threads are parked ( about 70%).
      The status snapshot before the failure looks like:

      Status Number of Threads : 382 Percentage
      Deadlock 0 0 (%)
      Runnable 16 4 (%)
      Waiting on condition 100 26 (%)
      Waiting on monitor 0 0 (%)
      Suspended 0 0 (%)
      Object.wait() 0 0 (%)
      Blocked 0 0 (%)
      Parked 266 70 (%)

      From what I can get from analyzer, threads ar parked by queue

      at sun/misc/Unsafe.park(Native Method)
      at java/util/concurrent/locks/LockSupport.park(LockSupport.java:184)
      at java/util/concurrent/locks/AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1998)
      at java/util/concurrent/LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
      at java/util/concurrent/ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:958(Compiled Code))
      at java/util/concurrent/ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      at java/lang/Thread.run(Thread.java:737)

      We can tune pool size and queue size with the config file, right now pol size is set to 50, queue size to 1024.

      My questions are:
      1) Can parked threads influence heap memory consumptions? Since it runs on jboss perhaps there are some mbeans listeners working with them?
      2) Will lowering the queue size help tp decrease the number of parked threads?

      Thanks,
      Sabina

      PS. I am relatively new to this, so feel free to point to some basic staff if needed

      Edited by: user8478083 on May 6, 2011 12:24 PM
        • 1. Re: Too many parked threads. Any memory impact ?
          jschellSomeoneStoleMyAlias
          Threads take memory. As long as they exist they take memory.

          What you have is not significant.
          Will lowering the queue size help tp decrease the number of parked threads?
          Is there something wrong with your application ?

          Is it failing? Is there a performance problem? Are you attempting to size your application via realistic loading?


          In other words why do you think that the number of parked threads is relevant?
          • 2. Re: Too many parked threads. Any memory impact ?
            833574
            Yes, as I mentioned above there are OOM crashes. I am searching for ways to decrease heap consumption. If at crash 70% of threads are parked it seems like they might not have been allocated proportionally, but this is just a guess.

            Edited by: n_sabina on May 7, 2011 11:49 AM

            Edited by: n_sabina on May 7, 2011 11:50 AM
            • 3. Re: Too many parked threads. Any memory impact ?
              jtahlborn
              about the only meaningful way to diagnose an OOM is to get the heap dump and analyze it. guessing is almost always useless.
              • 4. Re: Too many parked threads. Any memory impact ?
                833574
                Yes, I analysed heap dump too but there was only one case when most of memory was used by something not as generic as collections. There were Mbeans listeners, this is why I am trying to find a connection between them and parked threads.
                • 5. Re: Too many parked threads. Any memory impact ?
                  802316
                  Threads consume memory, mostly for their stack, but they don't consume a significant amount of heap.

                  It appears you have a lot of parked threads, but I don't believe this is that much of a problem.

                  Having a large number of listeners will be due to either something you are doing, or something you have configured. It is unlikely there is a connection with the number of threads. I suggest you profile the memory of your application when it is running. Pay close attention to when the listeners grows. i.e. is it mostly on start up, in which case it is not causing your OOM (otherwise it would OOM on startup), does it happen continuously whether the server is doing something or not, or does it only happen when you perform requests (if you can determine the specific request that would help). This will help you isolate the cause of the problem.
                  • 6. Re: Too many parked threads. Any memory impact ?
                    833574
                    Thank you Peter.