commons-fileupload DiskFileItemFactory / FileCleanerCleanup & memory

1 message Options
Embed this post
Permalink
Davis Ford

commons-fileupload DiskFileItemFactory / FileCleanerCleanup & memory

Reply Threaded More More options
Print post
Permalink
Hi, quick question on fileupload...

I have a gooogle web toolkit app that presents a UI to do the following:

1) Upload a file
2) Show a thumbnail of the upload after file has been uploaded
3) Repeat 1) and 2) if desired
4) Press Save -> Server takes files and puts them in final resting place

I can't afford to keep the files in memory for obvious reasons, so I need to
spill them to disk.  This is where the DiskFileItemFactory and the
FileCleanerCleanup become very useful.

My question revolves around memory usage, and ensuring I avoid
OutOfMemoryError.  After the #parseRequest( ) completes, I get the whole
byte array from the FileItem so I can create a thumbnail of it.

If I store the FileItem in the HttpSession after reading the byte array,
does it keep the byte array resident in memory, or is it just read from disk
and returned (i.e. GC'd after the servlet thread expires) ?

Regards,
Davis

--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977