How can we increase memory dynamically?

Prev      Next

Answer: No need - java does it automatically Try this.

class M {
   int m[];

   public M() { m = new int[1000]; }
}

public class MemAlloc {
   public static void main (String args[]) {
      M m[] = new M[1000000];
      for (int i=0 ; i < 1000000 ; i++) {
	 m[i] = new M();
	 try { Thread.sleep(10); } catch (Exception e) {}
      }
   }
}