High Processor Utilization

Jim Herold
  • Jim Herold

    Jim Herold - 2008-11-04

    I'm having issues running this under Tomcat. I built it with Maven, and use the resulting war file to deplay on Tomcat.

    Anytime I'm connected to the 3270 host, processor usage goes high on the server hosting Tomcat. I've tried different versions of Tomcat, as well as different versions of the JDK as well as building it on both Windows and Linux with the same result. It also doesn't matter whether Tomcat is running on Linux or Windows. The reported thread that's using all the CPU on Windows is "MSVCRT.DLL!endthreadex+0x3a" (MSVCR71.dll!endthreaqdex_0x31 after the JDK upgrade and rebuild). I don't have the tools to see the same on Linux, except that the high utilization process is java.bin.

    Another thing I noticed that might be helpful. I manually edited the index.jsp to increase the size of the applet window, and noticed that it appears there's a 2nd applet behind the 1st slightly offset towards the bottom (maybe it's not really there but an oddity with the way the window is drawn).

    So, any thoughts on how to deal with the high utilization? Any other info I can provide that might be helpful?

    Great looking app. Thanks for all the work you've done.


    • Jim Herold

      Jim Herold - 2008-11-18

      Thanks Jon, that did the trick. After doing that and rebuilding I'm back to the processor thrashing though. I inserted the same code I showed you in the 2nd message of this thread to fix it again (the while loop in Connection.java).

      • Jon Strayer

        Jon Strayer - 2008-11-19

        Ok, I see the problem now. I should be able to refactor this so that we don't have this problem. Just looking at the code I'd guess that the whole loop is unnecessary. All this thread does is start up to other threads. Those are the threads that do all the work. I'll have to try to figure out a way to test this.

    • Jim Herold

      Jim Herold - 2008-11-20

      It's very easy for me to test things, so let me know if there's anything I can do to help.

      Thanks Jon!!

    • Jim Herold

      Jim Herold - 2008-11-07

      I've put a bunch of time into this and have found where the issue lies. I've put a fix in place, but this being my 1st time diving into JAVA code I'm not sure it's the right solution.

      I took a thread dump using jstack and took a look at it in TDA, which showed that the thrashing was coming from line 281 of Connection.java within' the Proxy code. Line 281 is "while (!connectionClosed && !Thread.currentThread().isInterrupted()) {", which I presume is nothing more than a loop waiting for a Disconnect from the host.

      In order to eliminate the thrashing I inserted a 500ms sleep into the while loop using the following code;

      while (!connectionClosed && !Thread.currentThread().isInterrupted()) {
      try {
      } catch (Exception e) {

      With this code inserted my processor usage looks much better with no thrashing of any sort. So, did I handle that well, or is there a better way to do it?

      Thanks for a really nice app, and I look forward to feedback on this.


      • Jon Strayer

        Jon Strayer - 2008-11-09

        I'm not positive, but that might be fine. My problem is that you are using an older form of the proxy. The latest source is available here:


        I intend to try an get a release together, but work is busy and I don't have access to a 3270 host any more.

    • Jim Herold

      Jim Herold - 2008-11-12

      Ahh, SVN. That could explain alot. I've been getting the source from CVS on sourceforge, which apparently is out of date. I've got the SVN version now and will build that and see how it looks. I'll let ya' know what comes of that.


    • Jim Herold

      Jim Herold - 2008-11-17

      Hey again. I got the version from SVN built, and have been having mixed success with it. I finally made the connection this morning that it only works for me if I have both the CVS version and the SVN version deployed at the same time. When deploying without the CVS version I this appears in the localhost.*.log under Tomcat:

      Nov 17, 2008 10:13:57 AM org.apache.catalina.core.StandardContext loadOnStartup
      SEVERE: Servlet /freehost3270-web-1.0.0-SNAPSHOT threw load() exception
      java.lang.ClassNotFoundException: net.sf.freehost3270.web.ProxyLauncherServlet
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
      at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1094)
      at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
      at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
      at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:516)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

      I thought it might be a Tomcat version issue, but am getting the same result under Tomcat 5.5 and Tomcat 6. Any thoughts? I'll keep digging on my side and let ya' know what I come up with.

      Thanks for all your help Jon.


      • Jon Strayer

        Jon Strayer - 2008-11-17

        oops, I changed the package names but forgot to change the web.xml. In web/src/webapp/WEB-INF is a file named web.xml. Change the servlet entry to look like this:


        Or you can just get the fixed version out of subversion.


Log in to post a comment.