1

I am using Spring and Hibernate and try to upload large file but when i try to upload more then 150 Mb then it is generating error like

Caused by: java.lang.OutOfMemoryError: Map failed
at sun.nio.ch.FileChannelImpl.map0(Native Method)
at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:755)
... 157 more

I am using windows 64bit OS. After lots of googling i find that this is bug available in JDK. Can any one help me to solve this issue?

Some one write about this issue https://github.com/MLCL/Byblo/issues/78. but i am not sure this is bug or not. if bug then how can i resolve it. It any other appropriate solution for this.

subhash lamba
  • 216
  • 1
  • 14
  • Can you post the code that's doing this as well? We can't help unless we see what the code is actually trying to do. Thanks –  Apr 17 '14 at 11:34
  • actually code is not written by me. I am using liferay with spring and hibernate. Inside it i am uploading file using it Documents and media Portlets. – subhash lamba Apr 17 '14 at 11:36
  • I mean the code you're using to do the upload, I can appreciate that you're using third party code, but it would be helpful to see how your code is interacting with it. –  Apr 17 '14 at 11:37
  • Not a single line written by me. I am just uploading file. And generating this error in Log. Caused by: java.lang.OutOfMemoryError: Map failed at sun.nio.ch.FileChannelImpl.map0(Native Method) at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:755) ... 157 more – subhash lamba Apr 17 '14 at 11:39
  • http://stackoverflow.com/questions/12688778/increase-tomcat-memory-settings This will help – Lasitha Benaragama Apr 17 '14 at 11:43
  • 1
    Whatever library you're using is, very unwisely, using a memory-mapped file to save the upload, and the operating system won't memory-map the file beyond a certain size, for whatever reason. There's no need for memory-mapped I/O in this situation. Complain to the library supplier, and find another. – user207421 Apr 17 '14 at 12:07
  • Thank you for your reply. I also try to change plat form. I notice that it is working on another platform but not on mine. I am using java 7. Same configration with antoher platform where this programm work but not on mine. :( – subhash lamba Apr 17 '14 at 12:25
  • I try to contact liferay community but i think this is issue of JVM not of liferay. – subhash lamba Apr 17 '14 at 12:26
  • 1
    I agree with EJP. If you take a look at FileChannelImpl.map0(..) source code: http://hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/726e38af4020/src/windows/native/sun/nio/ch/FileChannelImpl.c you will see if that JNU_ThrowOutOfMemoryError(env, "Map failed") can occur only in case when file is too large. Check this out: http://stackoverflow.com/questions/19016512/c-mapviewoffile-fails – Ιναη ßαbαηιη Apr 17 '14 at 12:32
  • @subhashlambda Then you are mistaken. It is an issue of the native operating system, showing through as a Java exception. – user207421 Apr 17 '14 at 12:43
  • @ EJP : Now what can i do? i want to upload large file. – subhash lamba Apr 17 '14 at 12:49
  • @ Ivan Babanin thank for commant but please give me suggestion what can i do. Now i can not ignore liferay. – subhash lamba Apr 17 '14 at 12:52
  • @subhashlambda I've told you. Find another library. – user207421 Apr 17 '14 at 23:14
  • 1
    @ EJP : Yes i got you suggestion but now my project at end now i can not change my liferay CMS. is there any other way to perform this task. And like to say this is performing in only my platform not in all. This is not bug related to liferay. But there is problem in my Evn configuration of java. I try to upload same file in antoher liferay there is no error. – subhash lamba Apr 18 '14 at 04:06

1 Answers1

-3

Increase your JVM heap size?

-Xmx1024m
cbach
  • 394
  • 3
  • 8