我正在尝试将JSONArray添加到JSONObject。大部分时间这都可以正常工作,但有时会抛出OutOfMemoryError。
代码:
import org.dcm4che3.tool.dcm2jpg.Dcm2Jpg;
import java.io.File;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
org.apache.log4j.BasicConfigurator.configure();
Dcm2Jpg dcm2Jpg = new Dcm2Jpg();
try {
dcm2Jpg.convert(new File("/IMG.dcm"), new File("/IMG.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
堆栈追踪:
...
...
JSONObject oneField = new JSONObject();
oneField.put("qId", formQid);
oneField.put("value", finalEnumValuesJsonArray.toString());
//exception thrown at above line(FormUtils.java:1947)
...
...
可以采取哪些措施来防止此错误?