Why processing large files using camel causes java heap memory issues ?
Issue
- We have the following route
<threadPool id="bigPool" maxPoolSize="40" poolSize="40" threadName="Async Processor"/>
<route id="RequestRecieverRoute">
<from uri="cxf:bean:testService?dataFormat=PAYLOAD"/>
<log message="Test Message" loggingLevel="INFO" logName="INPUT" />
<threads executorServiceRef="bigPool">
<to uri="{{FilePath}}" />
</threads>
</route>
- When I am testing from soap UI using 4 threads, the fuse server is throwing heap issues as following. The input file is about 18 MB.
FileConsumer | 145 - org.apache.camel.camel-core - 2.12.0.redhat-610379 | Consumer Consumer[file://D:%5CPATH/TO/DESTINATION] failed polling endpoint: Endpoint[file://D:%5CPATH/TO/DESTINATION/TEST]. Will try again at next poll. Caused by: [java.lang.OutOfMemoryError - Java heap space]
java.lang.OutOfMemoryError: Java heap space
at java.util.ArrayList.iterator(ArrayList.java:774)[:1.7.0_04]
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_04]
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)[:1.7.0_04]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)[:1.7.0_04]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)[:1.7.0_04]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)[:1.7.0_04]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)[:1.7.0_04]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)[:1.7.0_04]
at java.lang.Thread.run(Thread.java:722)[:1.7.0_04]
.
.
.
Caused by: org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: org.apache.camel.component.cxf.CxfPayload@1ff96ee of type: org.apache.camel.component.cxf.CxfPayload on: Message: . Caused by: Error during type conversion from type: org.apache.camel.component.cxf.CxfPayload to the required type: java.io.InputStream with value org.apache.camel.component.cxf.CxfPayload@1ff96ee due java.lang.OutOfMemoryError: Java heap space. Exchange[Message: ]. Caused by: [org.apache.camel.TypeConversionException - Error during type conversion from type: org.apache.camel.component.cxf.CxfPayload to the required type: java.io.InputStream with value org.apache.camel.component.cxf.CxfPayload@1ff96ee due java.lang.OutOfMemoryError: Java heap space]
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:262)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
... 41 more
Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: org.apache.camel.component.cxf.CxfPayload to the required type: java.io.InputStream with value org.apache.camel.component.cxf.CxfPayload@1ff96ee due java.lang.OutOfMemoryError: Java heap space
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:173)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.core.osgi.OsgiTypeConverter.mandatoryConvertTo(OsgiTypeConverter.java:116)[152:org.apache.camel.camel-spring:2.12.0.redhat-610379]
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
... 42 more
Caused by: org.apache.camel.RuntimeCamelException: java.lang.OutOfMemoryError: Java heap space
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1005)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78)
at org.apache.camel.support.TypeConverterSupport.convertTo(TypeConverterSupport.java:39)
at org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertTo(CxfPayloadConverter.java:218)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_04]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:62)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:315)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
... 44 more
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.apache.xerces.dom.ElementImpl.setAttributeNode(Unknown Source)[:]
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1281)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1236)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1163)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1152)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1098)
at org.apache.camel.component.cxf.CxfPayload$1.get(CxfPayload.java:95)
at org.apache.camel.component.cxf.CxfPayload$1.get(CxfPayload.java:65)
at org.apache.camel.component.cxf.converter.NodeListWrapper.item(NodeListWrapper.java:37)
at org.apache.camel.converter.jaxp.DomConverter.toString(DomConverter.java:73)
at org.apache.camel.converter.jaxp.DomConverter.toByteArray(DomConverter.java:144)
at org.apache.camel.converter.jaxp.DomConverter.toInputStream(DomConverter.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_04]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001)
at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78)
at org.apache.camel.support.TypeConverterSupport.convertTo(TypeConverterSupport.java:39)
at org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertTo(CxfPayloadConverter.java:218)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_04]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001)
at org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:62)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:315)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
at org.apache.camel.core.osgi.OsgiTypeConverter.mandatoryConvertTo(OsgiTypeConverter.java:116)
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
at org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:262)
at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:278)
- We changed the JAVA_MIN_MEM ,JAVA_MAX_MEM, JAVA_PERM_MEM parameters in couple of bat files in the bin folder,like admin,client,karaf and patch bat files like following, but still it causes the above error.
:
if "%JAVA_MIN_MEM%" == "" (
set JAVA_MIN_MEM=512M
)
if "%JAVA_MAX_MEM%" == "" (
set JAVA_MAX_MEM=1024M
)
if "%JAVA_PERM_MEM%" == "" (
set JAVA_PERM_MEM=128M
)
if "%JAVA_MAX_PERM_MEM%" == "" (
set JAVA_MAX_PERM_MEM=256M
- After increasing the heap bit larger it causes the following error:
Caused by: org.apache.camel.RuntimeCamelException: java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1005)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78)
at org.apache.camel.support.TypeConverterSupport.convertTo(TypeConverterSupport.java:39)
at org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertTo(CxfPayloadConverter.java:218)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_04]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:62)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:315)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)[145:org.apache.camel.camel-core:2.12.0.redhat-610379]
... 21 more
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.lang.String.substring(String.java:1960)[:1.7.0_04]
at org.apache.xerces.dom.ElementNSImpl.setName(Unknown Source)[:]
at org.apache.xerces.dom.ElementNSImpl.<init>(Unknown Source)[:]
at org.apache.xerces.dom.CoreDocumentImpl.createElementNS(Unknown Source)[:]
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1257)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1236)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1163)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1152)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1098)
at org.apache.camel.component.cxf.CxfPayload$1.get(CxfPayload.java:95)
at org.apache.camel.component.cxf.CxfPayload$1.get(CxfPayload.java:65)
at org.apache.camel.component.cxf.converter.NodeListWrapper.item(NodeListWrapper.java:37)
at org.apache.camel.converter.jaxp.DomConverter.toString(DomConverter.java:73)
at org.apache.camel.converter.jaxp.DomConverter.toByteArray(DomConverter.java:144)
at org.apache.camel.converter.jaxp.DomConverter.toInputStream(DomConverter.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_04]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001)
at org.apache.camel.impl.converter.InstanceMethodTypeConverter.convertTo(InstanceMethodTypeConverter.java:78)
at org.apache.camel.support.TypeConverterSupport.convertTo(TypeConverterSupport.java:39)
at org.apache.camel.component.cxf.converter.CxfPayloadConverter.convertTo(CxfPayloadConverter.java:218)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_04]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_04]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_04]
at java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_04]
at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001)
at org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:62)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:315)
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:164)
at org.apache.camel.core.osgi.OsgiTypeConverter.mandatoryConvertTo(OsgiTypeConverter.java:116)
- While performing the SoapUI based load test we are using 32 bit Windows OS and 32 bit JVM.
Environment
- Red Hat JBoss Fuse
- 6.1.0
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.