Too many JAVA threads are seen in performance counters.

Hi All,

We are running RedHat ES 2.4.21-32 with Tomcat 5.0.25 + JDK 1.4.2_06 installed in it. Whenever the tomcat starts we see too many threads of JAVA. They can be seen when we use the TOP command and sort the listing using the memory consumtion. I have pasted the screen output below, where it shows many JAVA threads each using around 164M of memory.

If each JAVA thread is taking 164M of memory then I should be getting some memory errors as we only have 1GB of memory in the server. Where as I can still see some physical memory free in the screen.

=======================================================

Mem: 1024296k av, 942984k used,81312k free,0k shrd,76336k buff

383988k actv, 361032k in_d,832k in_c

Swap: 2096376k av,0k used, 2096376k free625116k cached

PID USERPRI NI SIZE RSS SHARE STAT %CPU %MEMTIME CPU COMMAND

23957 root250 164M 164M 32040 S0.0 16.40:080 java

23958 root150 164M 164M 32040 S0.0 16.4 15:201 java

23959 root150 164M 164M 32040 S0.0 16.40:001 java

23960 root150 164M 164M 32040 S0.0 16.40:010 java

23961 root250 164M 164M 32040 S0.0 16.40:001 java

23962 root250 164M 164M 32040 S0.0 16.40:001 java

23963 root150 164M 164M 32040 S0.0 16.40:050 java

23964 root150 164M 164M 32040 S0.0 16.40:551 java

23966 root150 164M 164M 32040 S0.0 16.40:001 java

23967 root150 164M 164M 32040 S0.0 16.40:000 java

23968 root150 164M 164M 32040 S0.0 16.40:001 java

23969 root150 164M 164M 32040 S0.0 16.40:000 java

23970 root150 164M 164M 32040 S0.0 16.40:000 java

23971 root150 164M 164M 32040 S0.0 16.40:000 java

=====================================================

And conversly, we get "Out of Memory" errors when we try to access our application when there are more than 15-20 users.

Can any one guide me where is problem, is it in JVM, TOmcat or in our configuration.

Regards

[1954 byte] By [Paralikara] at [2007-10-2 0:51:57]
# 1

1.) What you see are multiple threads = each thread shares memory -> altogether 164 mb.

2.) The 164mb include virtual adress space and a lot other stuff which is not in RAM.

3.) Use the -Xmx flag to set maximum heap, I would suggest something like -Xmx800m for you app.

lg Clemens

linuxhippya at 2007-7-15 18:11:36 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Hi Clemens,

- Do you have any idea why "TOP" utility shows me RAM is being consumed almost 99%. I have gone through the different processes that are running in the server, but didnt find any of them which are not consuming even all together a total of 100-150MB of RAM.

- We have only tomcat server running in it, no other applicatoin not even DB server.

- I have installed the same application in our testing server which is setup in the same lines. There I find only single thread of JAVA and consuming around the same memory and the TOP utility shows us OUR SERVER RAM still having 50% of memory free. The only difference here is the JVM which is 1.4.1_01-b01. In our production server (server I mentioned earlier) is having JVM 1.4.2_06-b03.

Why do think is this difference? Is it because of JVM or some misconfiguration?

Regards

Paralikara at 2007-7-15 18:11:36 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

If the OS works right memory will always be 100 used. Unused memory is wasted memory. Memeory not used by processes, it used for buffers and cache. Don't worry about that.

Swap used is mroe important. If you are using a lot of swap or is swap usage grows and grows you have too little ram for your needs.

fedetxfa at 2007-7-15 18:11:36 > top of Java-index,Java HotSpot Virtual Machine,Specifications...