大型Portlet战争占用了内存,从而导致性能问题? [英] Large portlet war takes up memory causing performance issues?

查看:108
本文介绍了大型Portlet战争占用了内存,从而导致性能问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说有人说部署包含很多大jar的portlet war文件(或者可能是任何war)可能会导致性能问题,因为所有这些jar都已加载到内存中.如果您有几次战争,所有战争都包括一吨大的jar文件,那么您的系统将陷入瘫痪.

I have heard a few people say that deploying a portlet war file (or perhaps any war) that includes a lot of large jars can cause performace issues because all those jars get loaded into memory. If you have several wars, all of which include a ton of large jar files, your system will get bogged down.

我正在努力弄清为什么这是真的-而且我还没有找到任何能以我理解的方式解释它的东西.也许我正在搜索错误的术语,这就是为什么我找不到太多信息的原因.任何人都可以解释当实例化portlet时,如果这些jar开始占用内存,究竟发生了什么?

I'm trying to get my head around why this is true - and I haven't found anything that explains it in a way that I get it. Maybe I'm searching for the wrong terms which is why I'm not finding much information. Can anyone explain what exactly is happening when a portlet gets instantiated and if indeed those jars start taking up memory?

推荐答案

简短的回答是:是的,部署带有大量jar的war文件可能"会导致性能问题.战争是否包含Portlet或标准Web应用程序都没有关系. 但我认为您不应该过早担心此问题,因为有解决此问题的简便方法.

The short response is: yes, deploying a war file with a lot of jars "could" cause performance issue. It does not matter if the war contains a portlet or a standard web application. But in my opinion you should not worry about this prematurely, because there are easy solutions for this problem.

将portlet或任何webApp加载到服务器时,它将主jar的类加载到Web服务器堆(分配给Java进程的内存)的"Permanent generation"区域中.该区域存储执行的代码.当这些类使用来自其他jar的代码时,它们的代码也将加载到该区域中. 如果这些区域已满,您将收到OutOfMemoryError异常.

When a portlet or any webApp is loaded into the server it loads the classes of the main jar into the "Permanent generation" region of the heap (memory assigned to the Java process) of the web server. This region stores the code that is executed. When these classes use code from other jars, their code is also loaded into this region. If this regions is filled up, you will get an OutOfMemoryError exception.

针对您的问题的解决方案很简单:

The solutions for your problems are easy:

  1. 为您的内存分配更多内存(JVM的参数-Xmx)

  1. Dedicate more memory to your memory (parameter -Xmx of the JVM)

如果您有几个带有相同jar文件的.war文件,请从war文件中删除这些jar,并将其放在Web服务器所有公共库所在的目录中.该目录的位置取决于您使用的Web App服务器.

If you have several .war files with the same jar files in them, remove those jars from the war files and put them in the directory where all the common libraries of the Web Server are located. The location of this directory depends on the Web App server that you are using.

因此,您不必担心此问题,因为它有解决方案.

So, you should not worry about this problem because it has a solution.

此PDF http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf 解释了内存管理在Java中的工作方式.它适用于常规Java应用程序和Web应用程序.

This PDF http://java.sun.com/j2se/reference/whitepapers/memorymanagement_whitepaper.pdf explains how memory management works in Java. It applies to regular Java apps and Web applications.

这篇关于大型Portlet战争占用了内存,从而导致性能问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆