[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compiler runs out of memory



> Check the JVM. Which Jdk ? The one from Sun, or Microsoft.
> Try the -X

I'm using the JVM with JBuilder from Borland. I tried the switch like this
"-Xmx50m" (it seems the Windows task manager was not providing useful
statistics, but I found a method that finds the amount of memory
availiable to the JVM). This works in limiting the JVM's memory use, but I
still get the same OutOfMemoryError. How much memory is needed for the
simplec example found on the sablecc site to work? Here is the method I
used for seeing how much is availiable:


public static final int MEGABYTE = 1048576;
public static long testMemory(int maximumMegabytesToTest)
{
  //For me, maximumMegabytesToTest was the value given by
  //the task mangager.
  
  //Hold on to memory, or it will be garbage collected
  Object[] memoryHolder = new Object[maximumMegabytesToTest];
  int count = 0;
  try
  {
    for (; count < memoryHolder.length; count++)
    {
      memoryHolder[count] = new byte[MEGABYTE];
    }
  }
  catch(OutOfMemoryError bounded){}
  long highWater = Runtime.getRuntime().totalMemory();
  //  System.out.println("High water in bytes: " 
  //  + highWater);
  //  System.out.println("Megabytes allocatable in 
  //  megabytes: " + count);
  memoryHolder = null; //release for GC
  //We know we could allocate "count" megabytes and 
  //have a high water mark of "highWater". Return 
  //whichever you prefer.
  //return count;
  return highWater;
}

Thanks,
Dave