-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 4.3.4
-
Fix Version/s: 4.4.2
-
Component/s: None
-
Labels:None
-
Environment:OS: Windows XP sp2
JDK: 1.5.12
Tomcat: 5.5.23
Large file(500MB+) upload causes out of memory exception.
I have checked the source code of liferay portal4.3.4. It uses commons fileupload to deal with file upload. In UploadServletRequest, it generates a LiferayServletRequest object which contains a LiferayInputStream object to manage input stream. Finally, pass this LiferayServletRequest to commons fileupload to process the upload function. Fileupload will store the uploading file to a temp file. It can prevent server from out of memory. However, the LiferayInputStream store a copy of uploading file into a ByteArrayMaker object(_cachedBytes) which is a child of ByteArrayInputStream. In this way, portal server not only stores the uploading file to filesystem but also stores a copy to memory(ByteArrayInputStream). So when user uploads a larger file, server would throw an out of memory exeception.