我的GWT应用程序中的内存泄漏

时间:2017-11-29 13:41:10

标签: java memory gwt memory-leaks

我有一个使用GWT创建的Web应用程序,它有内存泄漏。 老实说,我不能产生这种内存泄漏但是当我们在客户端环境中部署应用程序时,我们面临内存泄漏问题。

我收到这个文件也许它可以帮助我,当内存泄漏产生时它有内存中的对象。

2'777'369'064 (62.72%) [32] 8 class */planning/canvas/shared/serializable/ActionCycleSZ 0x68759f768
|- 2'777'365'536 (62.72%) [256] 35 org/apache/catalina/loader/WebappClassLoader 0x688ce9df8
|  |- 2'775'589'272 (62.68%) [48] 1 java/util/HashMap 0x688ceabe0
|  |  |- 2'775'589'224 (62.68%) [32'784] 3'533 array of java/util/HashMap$Entry 0x689af74c0
|  |     |- 2'763'509'944 (62.41%) [24] 2 java/util/HashMap$Entry 0x68a0b1f98
|  |     |  |- 2'763'509'744 (62.41%) [40] 1 org/apache/catalina/loader/ResourceEntry 0x68a0b1fb0
|  |     |  |  |- 2'763'509'704 (62.41%) [32] 41 class
*/gwt/server/servlet/TaProjectsSessionManager 0x68653c8e8
|  |     |  |     |- 2'763'047'360 (62.4%) [32] 6 class */selfservice/SelfConfigurator 0x6875922a0
|  |     |  |     |  |- 2'763'047'328 (62.4%) [16] 2 */gwt/server/servlet/TaProjectsSessionManager$1 0x689aee328
|  |     |  |     |  |  |- 2'154'573'968 (48.66%) [160] 30 */impl/HRSessionImpl 0x689ee49f8
|  |     |  |     |  |  |  |- 2'138'350'824 (48.29%) [32] 3 java/util/Collections$SynchronizedMap 0x689ee4c70
|  |     |  |     |  |  |  |  |- 2'138'350'760 (48.29%) [64] 3 org/apache/commons/collections/map/LRUMap 0x689ee5218
|  |     |  |     |  |  |  |  |  |- 2'134'913'368 (48.21%) [32] 2 org/apache/commons/collections/map/AbstractLinkedMap$LinkEntry 0x68a3573d0
|  |     |  |     |  |  |  |  |  |- 3'437'328 (0.08%) [2'064] 121 array of org/apache/commons/collections/map/AbstractHashedMap$HashEntry 0x68a356bc8
|  |     |  |     |  |  |  |  |  |- 16 (0%) [16] 1 org/apache/commons/collections/map/AbstractHashedMap$KeySet 0x69d443088
|  |     |  |     |  |  |  |  |- 32 (0%) [16] 2 java/util/Collections$SynchronizedSet 0x69d443098
|  |     |  |     |  |  |  |  |- 2'138'350'824 (48.29%) [32] 3 java/util/Collections$SynchronizedMap 0x689ee4c70
|  |     |  |     |  |  |  |- 16'078'096 (0.36%) [104] 19 */impl/Dictionary 0x689ee4ad8

我得出结论,类ActionCycleSZ可能会产生内存泄漏
这是ActionCycleSZ

public class ActionCycleSZ extends ActionDTO implements IsSerializable {
private CycleSZ bean;
public ActionCycleSZ() {
}
public ActionCycleSZ(Type actionType, CycleSZ bean ) {
super(actionType);
this.bean = bean;
}
public CycleSZ getBean(){
return bean;
}
public void setBean(CycleSZ bean){
this.bean = bean;
}
}
public class CycleSZ implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
String cycleLabel;
Date startDate;
Date endDate;
String startDateDTO;
String endDateDTO;
Integer numlign;
String accumulatedHours;
List<SiteSZ> listOfSites = new LinkedList<SiteSZ>();
//getter and setter
}
public class SiteSZ implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
int week;
String siteLabel;
Date startDate;
Date endDate;
String startHour;
String endHour;
String site;
String time;
String particularSlotTime;
Integer numlign;
DaySZ dayAttribute;
String accumulatedWeekHours;
Map<Util.WeekDays,DaySZ> mapAttributes = new LinkedHashMap<Util.WeekDays,DaySZ>();
boolean workedDay; //Flag for Exceptional Canevas Entry
boolean reposHebdo;
String contratId; //contratId for Exceptional Canevas Entry

ActionCycleSZ包含循环和操作(创建,删除,更新) 当用户创建或更新或删除此对象时,将显示此对象

eventBus.addHandler(CycleSaveEvent.TYPE, new CycleSaveHandler() {
        @Override       
        public void onCycleSaved(CycleSaveEvent event) {
final List<ActionCycleSZ> listCycleAction = new LinkedList<ActionCycleSZ>();
boolean newInsertion = getDetailsOfNewCycle(listCycleAction); //this methode can detect is there any new cycle and it will add actioncycleSZ 
        if (editedValuechange) {
            getDeletedCycle(listCycleAction);       
                    }                           
        if (!newInsertion) getDetailsOfOldCycle(listCycleAction);                                                                       getNotWorkedCycle(listOfNWSites,listCycleAction);
            updateCycle(listCycleAction);

当调用listCycleAction的方法updateCycle()将具有所有循环,因此该方法将调用RPC服务来保存循环

这是updateCycle

public void updateCycle(final List<ActionCycleSZ> listCycleAction) {
    //Call to service
     new  RpcCall2<String>() {
    @Override
        public void onFailure(Throwable caught) {
            deletedListOfCycleSZ.clear();
                view.setChantierGridUpdated(false);
}
@Override
        public void onSuccess(final String message) {
            isNewCycle=false;

                SC.say(TAMessages.getMessage("ta.canvas.cycle.saved"), new BooleanCallback() {
                @Override
                public void execute(Boolean value) {
                   /* popup to make the user know that the cycle is saved */
}}}
                           @Override
                            protected void callService(AsyncCallback<AsyncCallback<String> callback) {
                                canvasServices.updateListActionCreatedCycle(listOfEmployees, listCycleAction, true, callback);
                            }
                  }.call();

我没有看到任何可能导致内存泄漏的内容,因此我安装了JProfiler以了解更多我的问题,我注意到此对象的垃圾收集器无法正常工作

  

canvasServices.updateListActionCreatedCycle(listOfEmployees,listCycleAction,true,callback);

即使该方法为空,另一方面,如果我不在RPC调用中给对象,该对象将在内存中消失

内存泄漏的原因是什么?我在正确的道路上吗? 我想表明我正在使用GWT 2.5。是不是GWT会导致内存泄漏?

0 个答案:

没有答案