commons-fileupload DiskFileItemFactory / FileCleanerCleanup & memory

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

commons-fileupload DiskFileItemFactory / FileCleanerCleanup & memory

Davis Ford
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) ?


Zeno Consulting, Inc.
p: 248.894.4922
f: 313.884.2977