内存不足错误 - 超出GC开销限制

时间:2015-03-13 13:26:42

标签: java angularjs

我正在使用java中的XHTML转换器将DOCX文件转换为HTML文件。即我们正在将HTML文件下载到临时路径,然后我在浏览器中加载该HTML文件。但在转换之前,它会出现错误:

Error 404 not found

(在浏览器中)和

java.lang.OutOfMemoryError: GC overhead limit exceeded

(在控制台中)。

我在" XWPFDocument document = new XWPFDocument(in); "以下代码中的行。

String root = finalDestinationPath;
int lastIndex = sDocPath.lastIndexOf(File.separator);
String sFileName = sDocPath.substring(lastIndex + 1, sDocPath.length());
String fileNameWithOutExt = FilenameUtils.removeExtension(sFileName);
String fileOutName = root + File.separator + fileNameWithOutExt + ".html";
InputStream in = new FileInputStream(new File(sDocPath));
XWPFDocument document = new XWPFDocument(in);
XHTMLOptions options = XHTMLOptions.create();// .indent( 4 );
String sLocalSystemImagePath = finalDestinationPath + File.separator+"images"+File.separator;
            File imageFolder = new File(sLocalSystemImagePath);
            options.setExtractor(new FileImageExtractor(imageFolder));
            // URI resolver
            String localHostImagePath = downloadImagePath + File.separator+"images"+File.separator;
            FileResolver fileURIResolver = new FileResolver(new File(localHostImagePath));
            options.URIResolver(fileURIResolver);
             out = new FileOutputStream(new File(fileOutName));
            XHTMLConverter.getInstance().convert(document, out, options);

1 个答案:

答案 0 :(得分:0)

这意味着您的java进程没有足够的内存来转换该文件。