+ Start a Discussion
PremInfoPremInfo 

Out of memory while downloading Attachment

Hi Team,

 

I am trying to download the attachment from salesforce using SObject. Its working fine for the files less than 2MB size but failing with java out of memory : heap space error message for the file more than 2MB. We have the limit of 25MB in salesforce.

I have pasted the stack trace below. Your suggestion and guidance in this issue is much appreciated.

 

[Error]

java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2882)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
at java.lang.StringBuilder.append(StringBuilder.java:119)
at com.sforce.ws.bind.XmlObject.loadAfterStartTag(XmlObject.java:284)
at com.sforce.ws.bind.XmlObject.load(XmlObject.java:263)
at com.sforce.ws.bind.XmlObject.loadAfterStartTag(XmlObject.java:281)
at com.sforce.ws.bind.XmlObject.load(XmlObject.java:263)
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:628)
at com.sforce.ws.bind.TypeMapper.readArray(TypeMapper.java:528)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:506)
at com.sforce.soap.partner.QueryResult.loadFields(QueryResult.java:1)
at com.sforce.soap.partner.QueryResult.load(QueryResult.java:1)
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:628)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:504)
at com.sforce.soap.partner.QueryMoreResponse_element.loadFields(QueryMoreResponse_element.java:1)
at com.sforce.soap.partner.QueryMoreResponse_element.load(QueryMoreResponse_element.java:1)
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:628)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:504)
at com.sforce.ws.transport.SoapConnection.bind(SoapConnection.java:173)
at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:147)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:98)
at com.sforce.soap.partner.PartnerConnection.queryMore(PartnerConnection.java:1)
at com.informatica.cloudlabs.adapter.chatter.utils.ChatterHelper.getAllContentFeeds(ChatterHelper.java:271)
at com.informatica.cloudlabs.adapter.chatter.utils.ChatterHelper.fetchFeedItem(ChatterHelper.java:304)
at com.informatica.cloudlabs.adapter.chatter.read.ChatterRead.read(ChatterRead.java:97)
at com.informatica.cloud.api.adapter.reader.runtime.GenericRdrPartitionDriver.run(GenericRdrPartitionDriver.java:294)

 

[/Error]

Daniel HaselhanDaniel Haselhan

Have you specified the -Xmx java property to your web app server? And if so how much memory are you allocating?

 

If you are not, you may want to add this property and allocate more memory with -Xmx256m, this may solve your problem. This would happen if it was trying to copy a string/input that was greather than half the heap space.