자바 힙 메모리 관련 익셉션 질문
어서와
examList.add(new ImageIcon(examImg/1.jpg));
examList.add(new ImageIcon(examImg/2.jpg));
examList.add(new ImageIcon(examImg/3.jpg));
examList.add(new ImageIcon(examImg/4.jpg));
examList.add(new ImageIcon(examImg/5.jpg));
examList.add(new ImageIcon(examImg/6.jpg));
examList.add(new ImageIcon(examImg/7.jpg));
examList.add(new ImageIcon(examImg/8.jpg));
examList.add(new ImageIcon(examImg/9.jpg));
examList.add(new ImageIcon(examImg/10.jpg));
examList.add(new ImageIcon(examImg/11.jpg));
examList.add(new ImageIcon(examImg/12.jpg));
examList.add(new ImageIcon(examImg/13.jpg));
examList.add(new ImageIcon(examImg/14.jpg));
examList.add(new ImageIcon(examImg/15.jpg));
examList.add(new ImageIcon(examImg/16.jpg));
examList.add(new ImageIcon(examImg/17.jpg));
examList.add(new ImageIcon(examImg/18.jpg));
examList.add(new ImageIcon(examImg/19.jpg));
examList.add(new ImageIcon(examImg/20.jpg));
examList.add(new ImageIcon(examImg/21.jpg));
examList.add(new ImageIcon(examImg/22.jpg));
examList.add(new ImageIcon(examImg/23.jpg));
examList.add(new ImageIcon(examImg/24.jpg));
/*examList.add(new ImageIcon(examImg/25.jpg));
/***************** 이와같은 코딩에 아래와 같은 에러 메시지.
Exception in thread AWT-EventQueue-0 java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.init(Unknown Source)
at java.awt.image.Raster.createPackedRaster(Unknown Source)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
at sun.awt.image.SunVolatileImage.getBackupImage(Unknown Source)
at sun.awt.image.VolatileSurfaceManager.getBackupSurface(Unknown Source)
at sun.awt.image.VolatileSurfaceManager.initialize(Unknown Source)
at sun.awt.image.SunVolatileImage.init(Unknown Source)
at sun.awt.image.SunVolatileImage.init(Unknown Source)
at sun.awt.image.SunVolatileImage.init(Unknown Source)
at sun.awt.image.SunVolatileImage.init(Unknown Source)
at sun.awt.windows.WComponentPeer.createVolatileImage(Unknown Source)
at java.awt.Component.createVolatileImage(Unknown Source)좀 찾아본 결과 힙 메모리 초과인것 같은데 혹시 힙메모리를 늘려준다거나 다른 방법으로 메모리 문제 해결할 방법업나요?
위에 이미지 총 합쳐서 용량이 3메가도 채 안됩니다. 도와주세요 ㅠㅜ
-
등대
제가 보기엔 메모리 모니터링을 해 보시는 것이 좋을 듯 싶습니다.
3메가도 안 되는데, 디펄트로 64메가 잡고 가는 자바가 OutOfMemofy가 난다면 이상하네요.
파이널로 넘길 것은 넘겨버리고, 필요하다면 강제로 gc도 해주시고, 메모리가 누수되는 부분은 없는지 살펴보셔야 할 것 같습니다. -
물병자리
....
-
파랑
run - open run dialog - argument tab - VM argument에 -Xmx 를 넣어 주시면 됩니다.
우선 -Xmx에 대해서 조사를 하세요. -
가자
파일이 무지 큰가봐요.............?
-
바나나맛사탕
흠... 저 정도에 에러라면--;;;;
혹시라도 누수는 없는지...
뭐... 이래저래 생략하고... 메모리만 늘리고 싶으시다면...
이클립스 홈에 보시면 .ini파일이 있습니다. (아마도 eclipse.ini로 기억됩니다.)
해당 파일 열어 보시면 옵션에서 지정 가능합니다. -
자올
이클립스 쓰는데요 -Xmx 이거 어디에 넣어야 하나요? ㅠㅠ
-
그림자
힙메모리를 늘려주면 됩니다.
자바를 실행시킬때 -Xmx 옵션을 넣어서 실행해 보세요~ ( 아마도 맞을꺼예요. ㅎㅎ ) -
소미
24번까지 하면 에러 안나고 25번 주석빼면 에러 납니다 ㅜㅜ