Allocating many object

Frank Benoit frank at nix.de
Mon Mar 27 12:10:11 PST 2006


To see the difference to Java...

public class Alloc {

	int[] val;
	public Alloc()
	{
		val = new int[10];
	}
	
	public static void main(String[] args) {
		Alloc[] arr = new Alloc[1000000];
		for( int j = 0; j < 1000; j++ )
		{
	        	for( int i = 0; i < 1000; i++ )
	        	{
	            		arr[j*1000+i] = new Alloc();
	        	}
	        	System.out.println( "loop "+j );
	    	}
		System.out.println( "complete " );
	}
}


Note, this Java program make a second allocation for the array and does
also initialize the memory.

The program was finished after ONE second.
This 1000 times faster like the D program.

So I have to say that again... The GC is a show stopper and need to be
changed.








More information about the Digitalmars-d mailing list