Search code examples
javaservletsjakarta-eefootprint

What's the (memory) footprint of a Java EE servlet?


For Jetty, Tomcat, or any other servlet container of your choice, what's the average footprint (memory, and any other notable resources) of a basic servlet? This includes any other basic objects that you almost always need per servlet, such as a view resolver.

I'm not looking for a quantitative number in particular, but any indicative answer that could give an idea of how "heavy" or "lightweight" a servlet is.


Solution

  • I don't think this is something that you're getting much benefit from asking on Stack Overflow. The variability in the definition of "basic", and the different versions of servlet software, are going to be much greater than the amount of effort required to test this yourself.

    Simply create a "hello-world" type servlet that has no fields, fire up your servlet container(s) of choice with this WAR and measure memory usage. This will broadly give you the overhead of the servlet container, which you can then subtract from your actual memory measurements when seeing how "heavyweight" the target servlet is.

    The numbers will be much more useful if you generate themselves using the actual target version of the servlet container on the actual system in question, than someone replying here saying "47MB" or similar.