Using JConsole I saw that we seem to have a memory leak because not all the memory acquired while processing the SOAP message was freed. Several 100MB worth of byte[] were still pinned to the heap. Using Eclipse MAT with tracked this down to AWT Image referenced from an instance of org.apache.cxf.binding.soap.SoapMessage (via MessageImpl.contextCache) /from the native stack/. Starting the JVM with -Djava.awt.headless=true fixes this. Uploading a 50MB JPEG still consumes >1GB heap but at least the GC clears this.

Cheers,
Marcel

On 19.09.2012 23:28, Marcel Stör wrote:
I try to be precise and brief but all the config excerpts and
stacktraces will make this post long, sorry.

We developed a service (using CXF and Spring) that accepts images
through MTOM. I'm pretty sure CXF/MTOM is configured correctly. Still, a
50MB JPEG sent over the wire results in ~1.5GB in the heap. Something
seems amiss but I don't understand why/what...
I see that in $java.io.tmpdir/cxf-tmp-nnnnn the MTOM attachment is
dumped. I see in the stacktrace that MTOM is used because the
MTOMDecorator class shows up. I see in the inbound message (CXF
interceptor) a MIME message with an attachment.

If the heap is too small (e.g. 800MB) the java.lang.OutOfMemoryError
occur in different places depending on available heap obviously. Examples:
- Base64 decoding (stacktrace n/a anymore)
- Arrays.copyOf
- java.awt.image.DataBufferByte.<init>
-> http://pastebin.com/UjfRU9DN

[WSDL/XSD]
<xs:complexType name="attachment" abstract="true">
   <xs:sequence>
     <xs:element name="name" type="me:string255"/>
     <xs:element name="mimeType" type="me:string255"/>
   </xs:sequence>
</xs:complexType>
<xs:complexType name="imageAttachment">
   <xs:complexContent>
     <xs:extension base="me:attachment">
       <xs:sequence>
         <xs:element name="content" type="xs:base64Binary"
xmime:expectedContentTypes="image/jpeg, image/png, image/gif"/>
       </xs:sequence>
     </xs:extension>
   </xs:complexContent>
</xs:complexType>


[Spring config]
<jaxws:endpoint
    id="publicAPI"
    implementor="#publicAPIEndpoint"
    address="/publicAPI"
    wsdlLocation="my.wsdl"
    serviceName="myns:myservice"
    xmlns:myns="some-url">
   <jaxws:features>
     <bean class="org.apache.cxf.feature.LoggingFeature"/>
   </jaxws:features>
   <jaxws:properties>
     <entry key="schema-validation-enabled" value="true" />
     <!-- doesn't seem to make any difference -->
<!--       <entry key="mtom-enabled" value="true"/> -->
   </jaxws:properties>
</jaxws:endpoint>


[Inbound message excerpt]
Address: http://nb0131:8080/ws/publicAPI?runAs=zhapi
Encoding: UTF-8
Http-Method: POST
Content-Type: multipart/related; type="application/xop+xml";
start="<[email protected]>"; start-info="text/xml";
boundary="----=_Part_8_716120932.1348085609456"
Headers: {accept-encoding=[gzip,deflate], connection=[close],
Content-Length=[48725432], content-type=[multipart/related;
type="application/xop+xml"; start="<[email protected]>";
start-info="text/xml"; boundary="----=_Part_8_716120932.1348085609456"],
cookie=[JSESSIONID=E77F8B9C0B753BEE09F62D0EC9C4DFF3],
cookie2=[$Version=1], host=[nb0131:8080], mime-version=[1.0],
SOAPAction=[""], user-agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
Messages:
Message (saved to tmp file):
Filename:
C:\Users\mstoer\AppData\Local\Temp\cxf-tmp-357825\cos3686535214659827149tmp
(message truncated to 65536 bytes)

Payload:
------=_Part_8_716120932.1348085609456
...

Cheers,
Marcel



--
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

Reply via email to