java堆空间

时间:2012-12-14 16:33:57

标签: java-ee

当我执行我的程序包含2个循环,其中一个嵌套在另一个中时,我得到了这个错误OutOfMemoryError java heap space.i一直在寻找解决方案一周但没有结果。我知道可能问题在于创建实例我的循环因此需要大量的memory.son导致memmory leak.i尝试增加内存大小但这还不够。我的问题是如何在不执行大量内存的情况下开发相同的程序。这是我的程序。

public String getAllActionsJson(){
        //liste des actions de la table action
        List<Action> actions = actionService.getAllActions();
        //liste onglets de la table typeAction
        List<TypeAction> typesActions=actionService.getTypeActions();
        ActionNoeudJson actionRacine = null;
        ActionNoeudJson actionFeuille = null;
        List<ActionNoeudJson> listeFilles = null;
        for(int i=0;i<typesActions.size();i++)
        {
            listeFilles = new ArrayList<ActionNoeudJson>();
            actionRacine=new ActionNoeudJson();
            actionRacine.setId(typesActions.get(i).getId());
            actionRacine.setText(typesActions.get(i).getLibelle());
            for(int j=0;j<actions.size();j++)
            {
                //si le type de l'action est le meme que le type de l'onglet
                //on affecte actionFeuille à la racine courante(onglet approprié) 
                if(typesActions.get(i).getId()==actions.get(j).getTypeAction().getId())
                {   
                    actionFeuille = new ActionNoeudJson();
                    actionFeuille.setId(actions.get(j).getId());
                    actionFeuille.setText(actions.get(j).getLibelle());
                    actionFeuille.setIconCls("icon-tip");
                    listeFilles.add(actionFeuille);
                    actionRacine.setChildren(listeFilles);
                }   
            }
            listeActions.add(actionRacine);

        }
        return ActionSupport.SUCCESS;

    }

0 个答案:

没有答案
相关问题