cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Kulp (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-6632) Memory leak due to literal keys in WSDLDefinition map
Date Fri, 09 Oct 2015 15:17:26 GMT

    [ https://issues.apache.org/jira/browse/CXF-6632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14950544#comment-14950544
] 

Daniel Kulp commented on CXF-6632:
----------------------------------

Created a testcase that creates a client using a unique WSDL and makes a single call.   It
does that 10,000 times so 10K clients created from unique wsdl URL's

{code:java}
    @Test
    public void testMemoryLeak() throws Exception {

        URL wurl = getClass().getResource("/wsdl/hello_world.wsdl");
        byte wsdl[] = IOUtils.readBytesFromStream(wurl.openStream());
        final int max = 10000;
        
        List<URL> urls = new ArrayList<URL>(max); 
        for (int x = 0; x < max; x++) {
            File f = FileUtils.createTempFile("memtest", ".wsdl", FileUtils.createTmpDir(),
true);
            FileOutputStream fout = new FileOutputStream(f);
            fout.write(wsdl);
            fout.close();
            urls.add(f.toURI().toURL());
        }
        int count = 0;
        for (URL url : urls) {
            count++;
            if (count == 500) {
                count = 0;
                System.gc();
                long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
                System.out.println("Total used: " + used);
            }
            org.apache.hello_world_soap_http.SOAPService service 
                = new org.apache.hello_world_soap_http.SOAPService(url);
            Greeter greeter = service.getSoapPort();
            String response = new String("Bonjour");
            ((BindingProvider)greeter).getRequestContext()
                .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                     "http://localhost:" + PORT + "/SoapContext/SoapPort");
            greeter.greetMe("test");
            String reply = greeter.sayHi();
            assertNotNull("no response received from service", reply);
            assertEquals(response, reply);
        }
    }
{code}

The result is:

{code}
Total used: 158922560
Total used: 59764504
Total used: 53929024
Total used: 129572720
Total used: 116012352
Total used: 94773152
Total used: 75239248
Total used: 51025808
Total used: 31055768
Total used: 241753480
Total used: 30674872
Total used: 45508056
Total used: 52308928
Total used: 54434632
Total used: 55705784
Total used: 57832832
Total used: 56131208
Total used: 55707680
Total used: 56984672
Total used: 54434480
{code}

All values are within the same ballpark (not progressively increasing) so I'm not seeing any
sort of memory leak using normal use cases.     The URL's for the WSDL's are held onto strongly
in the list so if that was the issue, it should be seen here as well.

> Memory leak due to literal keys in WSDLDefinition map
> -----------------------------------------------------
>
>                 Key: CXF-6632
>                 URL: https://issues.apache.org/jira/browse/CXF-6632
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.7.17
>            Reporter: Giovanni Borelli
>            Assignee: Bharath Ganesh
>
> Looks like the definitionsMap in WSDLManagerImpl holds the WSDLDefinitions against a
weak key, again relying
> on the WeakHashMap semantics for removal.
> The loadDefinition(String) method loads the WSDLDef and puts this in a map
> against a String key even if it was passed as a URL through getDefinition(URL). 
> Like the https://issues.apache.org/jira/browse/CXF-1639 this causes a memory leak.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message