tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <>
Subject Re: tomcat won't download large files -- out of memory error
Date Fri, 26 Sep 2008 11:07:29 GMT
> I have some large zip files I want to make available for download.  When
> I try to download a 70MB file, tomcat is trying to cache these huge
> files (it seems).  The result is that downloading them always fails.  I
> *want* caching for most everything eg jpegs, html, etc and I've set
> tomcat to use up to 1.5GB of memory.

Do you mean you have set cacheMaxSize="1500000" on the context?

Which JVM are you using? Particularly, are you using a 32bit or 64bit JVM?

> Is there a way to limit the size of the file that will be cached?
Not at present. The maximum (cacheObjectMaxSize) is set to
(cacheMaxSize/20). I can see a case for making cacheObjectMaxSize
configurable. The cache should probably use the smaller of
(cacheMaxSize/20) and cacheObjectMaxSize.

> It's
> regrettable that failure to cache a file can't gracefully degrade into
> just not caching it.
It isn't possible to handle OOMs gracefully. Once they occur you have to
assume the JVM is toast and restart it.

Providing you have enough memory configured for the JVM to support the
cache size you have asked for plus the other memory you need to run Tomcat,
the cache will be fine and you won't see an OOM.

It appears in this case that the failure is that your JVM doesn't have
enough memory configured. With sufficient memory head room you should be
fine. The current cache implementation requires more headroom than is the
ideal. Limiting cacheObjectMaxSize should reduce the headroom required.


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message