You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2015/02/23 10:29:12 UTC

[Bug 57619] New: Memory consumption

https://bz.apache.org/bugzilla/show_bug.cgi?id=57619

            Bug ID: 57619
           Summary: Memory consumption
           Product: Tomcat 8
           Version: 8.0.18
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: jaroslav@kamenik.cz

I have inspected running tomcat containing two webapps with Eclipse Memory
Analyser and have found lots of same instances of String. For example

14300x "jar"
3100x
"/home/xxxx/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/wtpwebapps/XXXXXXXX/WEB-INF/lib/AppXXXXXXX.jar"

lots of similar long paths to other jars.

It is just few MBs of memory, but it could help a little to merge them somehow.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57619] Memory consumption

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57619

--- Comment #2 from Christopher Schultz <ch...@christopherschultz.net> ---
I tracked-down a bunch of similar issues in our own application several years
ago, and it turned out that the application framework (Struts 1, in our case),
was the culprit. We never found that Tomcat was a significant source of
"duplicate" strings.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57619] Memory consumption

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57619

Dmitri Blinov <dm...@mail.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |---
             Status|RESOLVED                    |REOPENED

--- Comment #3 from Dmitri Blinov <dm...@mail.ru> ---
I have found the similar simptoms that the multiple "jar" strings are allocated
by tomcat WebappClassLoader. The problem stems from usage of
java.net.URL(String spec) constructor for ResourceEntry. The
java.net.URL(String) parses the source and splits the "scheme" part, and by
forcibly converting it toLowerString a separate copy of "jar" string is created
for each new ResourceEntry. The problem can be solved by using different
java.net.URL(String protocol, String host, int port, String file) constructor,
where "jar" can by passed as a constant which could be shared by all instances
of created URL classes. 

I have created a small home test for Tomcat 7.0.82, which by means of
visualvm/heapdump showed that "jar" strings are realy shared among different
instances of URLs.

The code for example for Tomcat 7.0.82 is located in
org.apache.tomcat.buf.UriUtil.java, the commented lines are from previous
version:

    public static URL buildJarUrl(String fileUrlString, String entryPath)
throws MalformedURLException {
        String safeString = makeSafeForJarUrl(fileUrlString);
        StringBuilder sb = new StringBuilder();
        // sb.append("jar:");
        sb.append(safeString);
        sb.append("!/");
        if (entryPath != null) {
            sb.append(makeSafeForJarUrl(entryPath));
        }
        // return new URL(sb.toString());
        return new URL("jar", null, -1, sb.toString());
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57619] Memory consumption

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57619

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|REOPENED                    |RESOLVED

--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Thanks for the patch - it looks reasonable to me. My testing shows 7.0.x
benefits from this more, possibly due to the resources refactoring in 8.0.x
onwards.

Fixed in:
- trunk for 9.0.3 onwards
- 8.5.x for 8.5.25 onwards
- 8.0.x for 8.0.49 onwards
- 7.0.x for 7.0.84 onwards

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 57619] Memory consumption

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=57619

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from Mark Thomas <ma...@apache.org> ---
No analysis provided to suggest the proposed merging is even possible. (Chances
are it isn't without a lot of complexity else the JVM would have already done
it.)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org