ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • weka 메모리 사이즈 증가하기 ( Java heap space 오류 관련)
    프로그래밍/자연어처리 2017. 4. 2. 10:48
    반응형





    weka를 사용할 때 간혹 아래와 같은 java heap space 에러가 나는 경우가 있다. 


    에러가 없더라도 데이터 사이즈가 큰 경우 메모리는 충분한 사이즈로 세팅하는 것이 좋다. 


    java.lang.OutOfMemoryError: Java heap space

            sun.awt.image.ImageRepresentation.setPixels(Unknown Source)

            sun.awt.image.ImageDecoder.setPixels(Unknown Source)

            sun.awt.image.GifImageDecoder.sendPixels(Unknown Source)

            sun.awt.image.GifImageDecoder.parseImage(Native Method)

            sun.awt.image.GifImageDecoder.readImage(Unknown Source)

            sun.awt.image.GifImageDecoder.produceImage(Unknown Source)

            sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)

            sun.awt.image.ImageFetcher.fetchloop(Unknown Source)

            sun.awt.image.ImageFetcher.run(Unknown Source)

    ...




    윈도우에서 weka gui로 사용할 때 아래 설명과 같이 버전에 따라 메모리 설정 방법이 다르다. 




    Notes on Windows (RunWeka.bat, RunWeka.ini):
    The heap size can be changed by editing one of the files RunWeka.bat or RunWeka.ini, located in the Weka directory (e.g., C:\Program Files\Weka-3-4 for version 3.4.x), or by modifying the shortcut parameters. The following will describe which change to make, based on Weka version.
    • <= 3.5.2/<= 3.4.7
      Edit RunWeka.bat.
    • 3.5.3/3.4.8
      Weka comes with two shortcuts in the Windows Start Menu. Only the one with (console) in its name executes the RunWeka.bat batch file. If you use this shortcut to start Weka, increase the heap size in the batch file. The other shortcut starts Weka directly, avoiding the command prompt. If you use this shortcut, you must edit the parameters specified in the "Target" field for the shortcut in order to increase the memory.
    • >= 3.5.4/>= 3.4.9
      Modify the maxheap parameter in the RunWeka.ini file.




    현재 버전이 3.8.12 이라서  RunWeka.ini 파일을 아래와 같이 수정했다. 




    # placeholders ("#bla#" in command gets replaced with content of key "bla")

    # Note: "#wekajar#" gets replaced by the launcher class, since that jar gets

    #       provided as parameter

    maxheap=1024M

    ->

    maxheap=4096M






    참고로 리눅스에서 command line에서 사용할 때는 아래와 같이 -Xmx 옵션으로 메모리 사이즈를 설명해 주면 된다. 




    java -Xmx10240m -cp /home/weka-3-7-13/weka.jar weka.classifiers.functions.MultilayerPerceptron -T ${arffdir}/testdata.arff -c first -l ${modeldir}/mlp-mid.model -p 5-6 &> ${resultdir}/test.out







    참고: 


    http://weka.wikispaces.com/OutOfMemoryException


    http://weka.wikispaces.com/Java+Virtual+Machine







    728x90
    반응형
Designed by Tistory.