0

We are trying to upload large files(more than 6gb) through jQuery fileupload and in grails we accessing the file as MultipartFile. When trying to write the same into byte array, getting "out of memory"("Caused by OutOfMemoryError: Java heap space") exception.Code snippet.

        def finalName =new File("${path}/${newFile}")
        byte[] bytes = file.getBytes();
        BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(finalName ,true));
        stream.write(bytes);
        stream.close();

can anyone help me to resolve this issue without adding static heap size value in buildConfig.groovy file.

Thank you.

Süresh AK
  • 344
  • 3
  • 20
  • unsure what it has to do with buildConfig. https://stackoverflow.com/questions/37335/how-to-deal-with-java-lang-outofmemoryerror-java-heap-space-error-64mb-heap – V H Jul 17 '17 at 13:09
  • Can you try `Files.move(file, finalName, REPLACE_EXISTING);` ? – Krzysztof Atłasik Jul 17 '17 at 13:10
  • @vahid : We tried to increase heap size by adding grails.project.fork.compile.jvmArgs=['-Xss1024m'] line. – Süresh AK Jul 17 '17 at 17:41
  • @RandallFlagg : I tried the same. getting error. "Groovy.lang.MissingMethodException: No signature of method: static java.nio.file.Files.move() is applicable for argument types: (org.springframework.web.multipart.commons.CommonsMultipartFile, java.io.File, java.nio.file.StandardCopyOption) values: [org.springframework.web.multipart.commons.CommonsMultipartFile@24870838, ...] Possible solutions: move(java.nio.file.Path, java.nio.file.Path, [Ljava.nio.file.CopyOption;), wait(), grep(), find(), any(), every()" – Süresh AK Jul 17 '17 at 17:43
  • @SüreshAK and are you running the app within grails development or is on tomcat ? I hope you can start seeing gaps in your question. – V H Jul 17 '17 at 17:46
  • @vahid : Inside grails development environment. – Süresh AK Jul 17 '17 at 17:51

0 Answers0