简体   繁体   English

Java EE servlet的(内存)占用空间是多少?

[英]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? 对于Jetty,Tomcat或您选择的任何其他servlet容器,基本servlet的平均占用空间(内存和任何其他值得注意的资源)是多少? This includes any other basic objects that you almost always need per servlet, such as a view resolver. 这包括每个servlet几乎总是需要的任何其他基本对象,例如视图解析器。

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. 我不是特别想要一个定量数字,而是任何能够让人知道servlet“重”或“轻量”的指示性答案。

I don't think this is something that you're getting much benefit from asking on Stack Overflow. 我不认为这是你从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. “基本”定义的变异性以及servlet软件的不同版本将远远大于自己测试这一过程所需的工作量。

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. 只需创建一个没有字段的“hello-world”类型的servlet,使用此WAR激活您选择的servlet容器并测量内存使用情况。 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. 这将广泛地为您提供servlet容器的开销,然后您可以在查看目标servlet的“重量级”时从实际内存测量中减去。

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. 如果您使用实际系统上的servlet容器的实际目标版本生成自己,那么这些数字将更有用,而不是在这里回复说“47MB”或类似的人。

The container size is pretty irrelevant (Tomcat or Jetty, not Websphere or anything like that) unless you're doing embedded programming. 除非你正在进行嵌入式编程,否则容器大小是无关紧要的(Tomcat或Jetty,而不是Websphere或类似的东西)。 The Servlet size can be as small as you need it or as large as you need it. Servlet大小可以根据您的需要小到您想要的大小。 Generally speaking, stateless web applications will have less overhead per thread than stateful ones. 一般来说,无状态Web应用程序每个线程的开销将低于有状态Web应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM