Out of memory error - GC overhead limit exceeded

I am converting a DOCX file to HTML file using XHTML converter in java. i.e. we are downloading an HTML file to a temp path, and then I am loading that HTML file in the browser. But before conversion it gives an Error:

Error 404 not found

(in browser) and

java.lang.OutOfMemoryError: GC overhead limit exceeded

(in console).

I am getting error on the "XWPFDocument document = new XWPFDocument(in);" line in the following code.

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);

This means that your java process does not have enough memory to convert that file.