2 Replies Latest reply on Apr 18, 2003 4:22 AM by hris

    java.lang.OutOfMemoryError with CMR Collection

    afsilva

      Hi,

      I'm getting OutOfMemoryError with such simple code below. The collection returned by the CMR field 'pjs' has around 30000 elements. After getting the Pj object, I don't alter nor delete it. I've tried to breake the code in separete transactions, but in JBoss 3.0.6 I can't use a CMR Collection started in one trancation in a different one. If I increase the heap size of the JVM, solves the problem, but I think this is not a real solution.

      Enterprise enterprise = eh.findByPrimaryKey(new BigDecimal(idEnterprise));
      for (Iterator i = enterprise.getPjs().iterator(); i.hasNext();) {
      Pj pj = (Pj)i.next();
      // ... Inspect data, doesn't alter or delete
      }


      I'm using JBoss 3.0.6, jdk 1.4.0 and Oracle 8i, all under windows 2000.


      Please, is that some configuration option I'm forgetting to set, someone has already had this problem?

      Thanks,

      Andre

        • 1. Re: java.lang.OutOfMemoryError with CMR Collection
          hris

          What are your JVM memory settings?

          in the JBOSS_HOME/bin/run.bat, try to set the java settings to:

          %JAVA% %JAVA_OPTS% -Xms256m -Xmx256m -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %ARGS%

          As a rule of thumb, you can set the -Xms and -Xmx to 1/2 the available (physical) memory on your server. The default java settings are definitely not enough to run large apps. Plus, what's the point in gearing a sexy multi-Giga RAM server if you run java on 128MB?

          Hope this helps

          • 2. Re: java.lang.OutOfMemoryError with CMR Collection
            hris

            Looks like my last post doesn't show (???)
            Let's try again:

            set JVM memory settings in this file:

            JBOSS_HOME/bin/run.bat

            %JAVA% %JAVA_OPTS% -Xms128m -Xmx128m -classpath "%JBOSS_CLASSPATH%" org.jboss.Main %ARGS%

            128m = 128MB allocated to this java virtual machine.
            128MB is not enough for large or mem-hungry apps. should be at least 256MB or approx 1/2 the physical memory available on the machine.

            Laurent