日期:2014-05-17  浏览次数:20706 次

tomcat占用cpu很高
我用tomcat的datasource连接池,激活的是1000个连接,数据库用的是oracle10g。
现在遇到一个问题,linux进程里,java占得cpu基本是100%。
服务会很频繁的调用webservice接口,每次传100K左右的数据,
是不是服务器与webservice调用太频繁了,导致cpu升的很高呢??
大侠们  帮帮忙 谢谢啊!
tomcat webservice oracle10g

------解决方案--------------------
下面是用来列举所有线程的jsp页面: 

<html>  

02 <head>  

03 <title>Threads in ldcstudy.com</title>  

04 <style>  

05 body {font-size:8pt;}  

06 ol {line-height:18px;}  

07 </style>  

08 </head>  

09 <body>  

10 <strong>java.io.tmpdir:</strong>  

11 <ul>  

12 <li><%=System.getProperty("java.io.tmpdir")%></li>  

13 </ul>  

14 <br/>  

15 <strong>Memory:</strong>  

16 <ol>  

17 <li>freeMemory=<%=Runtime.getRuntime().freeMemory()/(1024*1024)%>M</li>  

18     <li>totalMemory=<%=Runtime.getRuntime().totalMemory()/(1024*1024)%>M</li>  

19     <li>maxMemory=<%=Runtime.getRuntime().maxMemory()/(1024*1024)%>M</li>  

20 </ol>  

21 <br/>  

22 <strong>Thread:</strong>  

23 <ol>  

24 <%for(Thread t : list_threads()){%>  

25 <li><%=t.getName()%>(<b><%=t.getState()%></b>) : <%=t.getClass().getName()%></li>  

26 <%}%>  

27 </ol>  

28 <%!  

29 public static java.util.List<Thread> list_threads(){  

30     int tc = Thread.activeCount();  

31     Thread[] ts = new Thread[tc];  

32     Thread.enumerate(ts);  

33     return java.util.Arrays.asList(ts);  

34 }  

35 %>  

36 </body>  

37 </html> 


导致CPU 100%的原因,有可能是程序某个地方存在死循环,这个死循环在某种条件下存在,因此通过上面的方法可能找出来。还有可能是连接为关闭等导致的