java.util.jar.jarfile.init() method takes too long to execute

蹲街弑〆低调 提交于 2020-01-04 04:17:26

问题


Story: I am resolving some performance issues on my Web Application Application background: This Application is written in Java, with Velocity Template Engine, and front-end javaScript using Tomcat9 server.

Problem: When i leave the application running, for 10-15 min, the application slows down, So i tried to do VisualVM profiling, and found some traces, that i want to share with you people.

UPDATE
I debug it more, and find the main reason of redundant calls to Open function in RandomAccessFile

and this is the call stackeTrace

In StandardRoot.java we have one method, which looks for Resources

private WebResource getResource(String path, boolean validate,
        boolean useClassLoaderResources) {
    if (validate) {
        path = validate(path);
    }

    if (isCachingAllowed()) {
        return cache.getResource(path, useClassLoaderResources);
    } else {
        return getResourceInternal(path, useClassLoaderResources);
    }
}

and this function calls getResourceInternal which leads to load resources again and again, if it still available

I tried to find some Tomcat configurations too. and i did some changes regarding to that like

in context.xml

<Context>
<Resources cachingAllowed="true" cacheTtl="36000000" cacheMaxSize="51200"/>

.........
..........
</Context>

This helps me to increase the time to cache the objects like by default cacheTtl is 5 seconds, I increased this to 1 hour and cachingAllowed true and cacheMaxSize is set to 50mb

I was able to load and read these parameters in StandardRoot.java but my calls to read Library file is not decreased.

So basic problem is When I leave my application running(Means running on Tomcat server but not using on web browser) for 10-15 min, the application slows down, and when I did profiling of Application, I found this

java.util.jar.JarFile.init() method took 46 seconds

What solution i need: if someone faced this kind of issue, or know where now i can further look-into, that would be good, Now I am facing stuck

Thanks in advance :)

PS: I erased some file names. because they are private and need to be secured thanks for not asking what are these files :)

来源:https://stackoverflow.com/questions/57347100/java-util-jar-jarfile-init-method-takes-too-long-to-execute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!