当在JobApplicationContext中放置一个大对象时,出现以下错误。该对象将转换为JSON并保存在BATCH_JOB_EXECUTION_CONTEXT中,但不知道为什么在处理writer步骤时我们内存不足。
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
at java.lang.StringBuffer.append(StringBuffer.java:270)
at java.io.StringWriter.write(StringWriter.java:101)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1238)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1234)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1234)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1234)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.json.JSONArray.write(JSONArray.java:848)
at org.codehaus.jettison.json.JSONObject.write(JSONObject.java:1236)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeJSONObject(MappedXMLStreamWriter.java:258)
at org.codehaus.jettison.mapped.MappedXMLStreamWriter.writeEndDocument(MappedXMLStreamWriter.java:244)
at com.thoughtworks.xstream.io.xml.StaxWriter.endNode(StaxWriter.java:149)
at com.thoughtworks.xstream.io.WriterWrapper.endNode(WriterWrapper.java:37)
at com.thoughtworks.xstream.io.path.PathTrackingWriter.endNode(PathTrackingWriter.java:48)
at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:83)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)