重新启动应用程序后出现WebSphere Memory Leak

时间:2016-09-05 15:55:00

标签: java jsf memory-leaks websphere

我正在使用Eclipse MAT分析我的WAS 8.5的头部转储。

我在一开始就提取了一个非常大的Head Dump,大约700 MB,我发现com.ibm.ws.webcontainer.webapp.WebAppImpl有很多重复的条目(见下图)。

enter image description here

在它下面可以找到的主要对象是我的JSF应用程序中的一个名为DataUtils的类,这个类是一个具有eager等于true的Application Scoped Bean,它在启动应用程序时运行以加载一些数据并将它们存储在内存中。

enter image description here

我认为这个bean所采用的大小不应该是一个问题,但是重复的对象会导致这个巨大的内存。

现在为了确定我为什么会有这些重复的对象,我重新启动了服务器,然后启动了WAS和应用程序,我进行了头部转储并对其进行了分析,一切都很好,尺寸非常小50 MB。 (我现在知道DataUtils已经初始化并且数据已加载了)

然后我停止了应用程序,然后再次启动它,知道DataUtils将要初始化,我进行了头转储并找到了第一个重复的WebAppImpl对象。

enter image description here

您还可以注意到红色标记,DataUtils类是重复的。

第二次停止开始后,重复次数增加。

enter image description here

我不确定我是否提供了足够的信息,即使我的假设(约DataUtils)是正确的。但是,是否已知Application Scoped bean不会从内存中销毁?还有什么可能导致这个问题?

感谢。

更多信息

安装了另一个应用程序。

DataUtils是一个Application Scoped Bean。它会注入其他一些Beans(它们同时是Spring bean)。

@ManagedBean(name = "dataUtils", eager=true)
@ApplicationScoped
public class DataUtils implements Serializable {

    private static final long serialVersionUID = 1L;

    @ManagedProperty(value = "#{serviceFactoryExternal}")
    private ServiceFactoryExternal serviceFactoryExternal;
    public ServiceFactoryExternal getServiceFactoryExternal() {return serviceFactoryExternal;}
    public void setServiceFactoryExternal(ServiceFactoryExternal serviceFactoryExternal) {
        this.serviceFactoryExternal = serviceFactoryExternal;}

    @ManagedProperty(value = "#{serviceFactoryOperational}")
    private ServiceFactoryOperational serviceFactoryOperational;
    public ServiceFactoryOperational getServiceFactoryOperational() {return serviceFactoryOperational;}
    public void setServiceFactoryOperational(ServiceFactoryOperational serviceFactoryOperational) {
        this.serviceFactoryOperational = serviceFactoryOperational;}

    @ManagedProperty(value = "#{serviceFactoryHistorical}")
    private ServiceFactoryHistorical serviceFactoryHistorical;
    public ServiceFactoryHistorical getServiceFactoryHistorical() {return serviceFactoryHistorical;}
    public void setServiceFactoryHistorical(ServiceFactoryHistorical serviceFactoryHistorical) {
        this.serviceFactoryHistorical = serviceFactoryHistorical;}

    @ManagedProperty(value = "#{serviceFactoryLDAP}")
    private ServiceFactoryLDAP serviceFactoryLDAP;
    public ServiceFactoryLDAP getServiceFactoryLDAP() { return serviceFactoryLDAP; }
    public void setServiceFactoryLDAP(ServiceFactoryLDAP serviceFactoryLDAP) { this.serviceFactoryLDAP = serviceFactoryLDAP; }


    @PostConstruct
    public void init() {
        listCountriesEnglish = serviceFactoryOperational.getCountryService().findAll("EN");
        listCountriesFrench = serviceFactoryOperational.getCountryService().findAll("FR");
        listBanks = serviceFactoryOperational.getBankService().findAll();
        listBranches = serviceFactoryOperational.getBankService().findAllBankBankBranches();
        listJudStatusEnglish = serviceFactoryOperational.getJudStatusService().findAll("EN");
        listJudStatusFrench = serviceFactoryOperational.getJudStatusService().findAll("FR");
        listCreditPortfolioEnglish = serviceFactoryOperational.getCreditPortfolioService().findAll("EN");

//Filling lists from database....

    }
    // List of Beans
    private static List<CountryBean> listCountriesEnglish;
    private static List<CountryBean> listCountriesFrench;
    private static List<Bank> listBanks;
    private static List<BankBranchesBean> listBranches;
    private static List<odatabase.service.beans.JudStatusBean> listJudStatusEnglish;
    private static List<odatabase.service.beans.JudStatusBean> listJudStatusFrench;
    private static List<odatabase.service.beans.CreditPortfolioBean> listCreditPortfolioEnglish;
    private static List<odatabase.service.beans.CreditPortfolioBean> listCreditPortfolioFrench;
    private static List<odatabase.service.beans.ClientClassBean> listClientClassEnglish;
    private static List<odatabase.service.beans.ClientClassBean> listClientClassfrench;
    private static List<odatabase.service.beans.RegistrationCommerce> listRegCommEnglish;
    private static List<odatabase.service.beans.RegistrationCommerce> listRegCommFrench;
    private static List<LegalFormBean> listLegalFormPPEnglish;
    private static List<LegalFormBean> listLegalFormMPEnglish;
    private static List<LegalFormBean> listLegalFormPPFrench;
    private static List<LegalFormBean> listLegalFormMPFrench;

    private static List<FamStatusBean> listFamStatusEnglish;
    private static List<FamStatusBean> listFamStatusFrench;
    private static List<MohafazaBean> listMohafazaEnglish;
    private static List<MohafazaBean> listMohafazaFrench;
    private static List<KadaaBean> listKadaaEnglish;
    private static List<KadaaBean> listKadaaFrench;
    //Other Lists...

//Other simple private methods..
}

其中一只注入的春豆:

@ManagedBean(name="serviceFactoryExternal", eager=true)
@Component
@ApplicationScoped
public class ServiceFactoryExternal {

    @Autowired
    private  BcrClientService clientService;
    public void setClientService(BcrClientService clientService) { this.clientService = clientService; }
    public  BcrClientService getClientService() { return this.clientService; }

//Other Injected Spring Beans, no post construct.
}

0 个答案:

没有答案