CARI Infonet

 Forgot password?
 Register

ADVERTISEMENT

View: 2379|Reply: 4

java.lang.OutOfMemoryError: Java heap space

[Copy link]
Post time 8-8-2007 09:53 PM | Show all posts |Read mode
aku try nak run build(untuk web ) untuk projek aku ni.. and error die adalah

Buildfile: C:\Sandbox\Sandbox\projek-web\build.xml
clean:
   [delete] Deleting directory C:\Sandbox\Sandbox\projek-web\www
gwt-compile:
    [mkdir] Created dir: C:\Sandbox\Sandbox\projek-web\www
     [java] Output will be written into www\com.company.projek.Home
     [java] Analyzing permutation #1
     [java] [ERROR] Unexpected internal compiler error
     [java] java.lang.OutOfMemoryError: Java heap space
     [java] [ERROR] Build failed
     [java] Java Result: 1

aku gune eclipse and GWT  dan  jboss
aku dah try untuk tambah java heap size tu pada jboss.. tapi problem still ade jugak...
adekah sape2 yang tau bagaimana untuk menyetelkan masalh ini?
Reply

Use magic Report


ADVERTISEMENT


Post time 9-8-2007 06:45 PM | Show all posts

Reply #1 ammameiya's post

Biasanya berlaku kalau program java ko guna dynamic data structure macam vector atau hashmap dan multidimensional array yang menjadi terlampau besar. Ko boleh buat 2 perkara:

1. transfer states ke hard disk dan ambil bila perlu.
2. allocate bigger memory utk jvm:
You can't do it from within the application, you have to do it when you start the application. Increasing the min and max memory of the application is done by using the VM arguments -Xms###M and -Xmx###M, where # should be replaced with the amount of memory which you want to allocate in megabytes. -Xms is inital size, and -Xmx is maximum size of the heap.

Example of usage:
java -Xmx512M Main

Starts the class Main with 512MB of memory as maximum heap size.

rujuk: http://forum.java.sun.com/thread ... 2&messageID=3716437
Reply

Use magic Report

 Author| Post time 10-8-2007 10:10 AM | Show all posts

Reply #2 alusmetai's post

yg solution ke 2 tu aku dah cube... tp mcm tu lah jugak

yg solution pertama tu mcm mane plak ye??

btw, coding aku ni lebih kurang mcm ni ::aku dah dapat detect problem die , bila aku komenkan baris 1 hingga 4 (untuk create rpc service tu) program aku okey..
masalh berlaku bile aku uncommentkan ..bile aku build tu die kuar error java.lang.OutOfMemory tu le..

public class NamaKelas  extends Composite{
        final Label title= new Label();
        final TextBox carian = new TextBox();
        final ListBox listBox = new ListBox();
        final Button exit = new Button();
        final Button cariB = new Button();
        final Button dtlExit = new Button("Keluar");
        final Button sebelum = new Button("Sebelum");
        final Button berikut = new Button("Berikut");

        final FlexTable setiaList = new FlexTable();       //
        final FlexTable headerList = new FlexTable();       //
        final FlexTable dtlFlex  = new FlexTable();          //


        final VerticalPanel detailPanel = new VerticalPanel();
        final FlowPanel berikutPanel = new FlowPanel();
        final RootPanel mainPanel = RootPanel.get();
        
        int start = 0;
        int page_size = 3;
        int total_data;
        String dataCarian;
        int indexAtList;
        
NamaKelasServiceAsync namaService;
        
        
  public NamaKelas(){
         
namaService= (NamaKelasServiceAsync )GWT.create(NamaKelasService.class);               -----1
ServiceDefTarget m = (ServiceDefTarget) namaService;                                                      ------2
String relativeURL = GWT.getModuleBaseURL() + "NamaDCS";                                      ------3
m.setServiceEntryPoint(relativeURL);                                                                                 -------4

           mainPanel.clear();
                title.setText("SENARAI ");
                listBox.addItem("TAHUN");
               

                Grid cariGrid = new Grid(2,4);
                cariB.setText("Cari");
                exit.setText("Keluar");
                cariGrid.setText(0, 0, " Carian ");
                cariGrid.setWidget(0, 1, carian);
                cariGrid.setText(0, 2, " berdasarkan ");
                cariGrid.setWidget(0, 3, listBox);
                cariGrid.setWidget(1, 2, cariB);
                cariGrid.setWidget(1, 3, exit);
                mainPanel.add(title);
                mainPanel.add(cariGrid);

                mainPanel.add(headerList);
                mainPanel.add(setiaList);
           
                berikutPanel.add(sebelum);
            berikutPanel.add(berikut);
           
                mainPanel.add(berikutPanel);
               

           
                        } //end of constructor
Reply

Use magic Report

Post time 10-8-2007 07:00 PM | Show all posts
cuba alternatif ke 2 tu untuk value memory lebih besar lagi atau set permsize jboss tu dgn value lebih besar lagi.

try this command buddy:

javac -J-Xmx1024M Your_Class.java
Or

if u r using some application server like JBoss to deploy,
u'll probably have to tweak the run.bat it a bit to inc. the memory


eg:
set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m

rujuk: http://www.javaworld.com/javaforums/showflat.php?Number=42759&page=0


In my opinion, very little can u do menggunakan alternatif 1 kalau memory yg leak tu disebabkan oleh GWT seperti yang aku suspek selepas ko bagitau ianya berlaku apabila ko try instantiate service gwt tu. Tetapi, kalau ko ada running NamaKelas dari somewhere else dalam program ko secara recursive atau looping infinitely atau instantiate NamaKelas terlampau banyak, avoid doing that.

Good luck.

[ Last edited by  alusmetai at 10-8-2007 07:07 PM ]
Reply

Use magic Report

Post time 16-8-2007 09:09 AM | Show all posts
kalu aku guna JDEVELOPER 10g, so kat properties project tuh kat run/debug n kat virtual machine setkan dia sebagai ojvm..
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

9-6-2024 08:18 AM GMT+8 , Processed in 0.055235 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list