다른 루프에 중첩 된 2 개의 루프를 포함하는 내 프로그램을 실행할 때 OutOfMemoryError java heap space.i가 1 주일 동안 해결책을 찾고 있었지만 result.i는 문제가 있음을 알고 있습니다. 인스턴스를 생성 할 때마다 많은 시간이 걸리므로 메모리 누수가 발생합니다. 메모리 크기를 늘리려고했지만 충분하지 않습니다. 내 질문은 어떻게 excution.this에 많은 메모리를 사용하지 않고 동일한 프로그램을 개발할 수 있습니다 내 programm이야.java heap space
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;
}
아마도 메모리 누수가있을 것입니다. 루프에서 사용한 후에 재사용 된 변수를 null로 설정하려고합니다. 나는 이것이 당신의 문제인지 잘 모르겠지만 시도 할 만하다. 구글 메모리 누수를 해결하는 방법을 구글 검색 – Codeguy007
나는 일주일 동안 유일한 주어진 솔루션은 실행 구성에서 명령 -Xmx512m로 메모리 크기를 늘리고있다하지만 그 증상이 아닌 질병에 치료를 봤는데 이 알고리즘을 내 질문에 공유하고 있습니다 –
https://www.google.ca/search?q=how+to+debug+a+java+memory+leak&aq=f&oq=how+to+debug+a+java+ memory + leak & aqs = chrome.0.57j0j62l3.15404 & sugexp = chrome, mod = 12 & sourceid = chrome & ie = UTF-8 – Codeguy007