开发者

Grails File Upload: Tomcat Memory Drain

We're noticing some significant RAM usage while uploading files. I pretty much expect that but the rate at which the memory is freed seems pretty slow. And this is causing the whole system to slow down, obviously, when RAM gets too low.

Is there anything that can done, short of adding more RAM, to help improve either the general performance and RAM usage of file uploads or the rate at 开发者_运维知识库which objects are GC'd once an upload is complete? Server settings in Tomcat6? Something in Grails itself?


How are you handling the file uploads, as described in the Grails manual? That may not be good enough for you if you expect quite some concurrent file uploads (of considerable size) which are very memory consuming.

Seems to me you want to try to let your app keep the uploaded content on disk, not keep it in memory (before it passes the file content to your controller)

Grails uses Commons Fileupload under the hood. In your case it maybe more practical to write a controller that does the handling in a way that is a bit more involved than the regular grails way. Maybe the streaming API is what you want, or the regular way (scroll down to 'Resource cleanup') but with a disk store instead of memory. I think you can just use the code on that page in your controller-action. Commons Fileupload is already on your classpath

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜