Reputation: 2367
First of all, I lie, it's not really a plain jsp website. It has a couple of pages with database access and a lucene based search engine... and around 400 standalone jsp pages.
The problem is that the admins on a production server we've not access to, say that the site is consuming too much memory (200+ Megs), and we are probably facing a memory leak, because it forces them to reboot it.
I'm not a jsp expert, but I suspect that it's not really a memory leak, and that the database pages and the lucene search have nothing to do with this issue. I understand that each jsp page is compiled to a java class, then executed, and kept in memory for later access.
The real question is: Can this elevated (for 400, i think yes) number of standalone jsp pages cause the memory usage to grow up to 200M?
And if yes, how would you lower the memory usage? Using SSIs for includes (avoiding the use of jsp pages for that purpose) could be an option?
Thanks in advance
Upvotes: 0
Views: 2866
Reputation: 55907
Half a megabyte per JSP is not what I'd usually expect. Obviously, one can write any code one likes in a JSP so a compiled jsp can be huge and can allocate huge amounts of memory, but assuming that these are conventional JSPs then I'd me most suspicious of run-time behaviours rather than the shear number of JSPs.
One possibility is that you have a lot of session data. As users move from page to page the session size might be increasing. It's quite common to see data retrieved from a database temporarily place in a session so that it can be used in another page. If that doesn't get tidied up you can rapidly consume lots of memory.
Upvotes: 1
Reputation: 1991
You need to determine where that memory is spent. The statement that 200MB is too much is really useless, as it depends on the usage, how the application is using memory (e.g. session data as David mentioned). You need to analyse heap dumps and verbose gc logs from various times in the application's lifecycle to understand the usage and whether you do in fact have a memory leak (if the application is stable at 200MB you don't. If it increases every x hours with no sign of decreeasing, you probably do).
Upvotes: 0
Reputation: 30448
The only way to know what consumes the memory is to use a profiler. What we do is to take a heap dump and then analyse it, in the following manner:
Regardless, it is always good to pre-compile the JSPs before the server boots.
Upvotes: 1