Hi again Steve, or anyone else whose reading this.
I was playing around with D and C# and need help getting this array stuff to work.

My D program:
import std.stdio, std.cstream, std.array;

void main()
{
        string[] temp_array = new string[100000000];
        for(int i=0;i<100000000;i++)
        {
                temp_array[i] = "aaaaaaaaaaaaaaaaaaaaa";
        }               
        temp_array = null;
        
        temp_array = new string[100000000];
        for(int i=0;i<100000000;i++)
        {
                temp_array[i] = "aaaaaaaaaaaaaaaaaaaaa";
        }
        temp_array = null;
        
        writeln("end");       

        din.getc();
}

This program causes an OutOfMemoryError.


My C# program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace testing
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] temp_array = new string[100000000];
            for (int i = 0; i < 100000000; i++)
            {
                temp_array[i] = "aaaaaaaaaaaaaaaaaaaaa";
            }
            temp_array = null;

            temp_array = new string[100000000];
            for (int i = 0; i < 100000000; i++)
            {
                temp_array[i] = "aaaaaaaaaaaaaaaaaaaaa";
            }
            temp_array = null;

            temp_array = new string[100000000];
            for (int i = 0; i < 100000000; i++)
            {
                temp_array[i] = "aaaaaaaaaaaaaaaaaaaaa";
            }
            temp_array = null;


            Console.WriteLine("end");
            Console.ReadKey(true);
        }
    }
}

It's the same program, but doesn't cause and OutOfMemory exception, even if i double the times i run the loop part.

My question is what is how do i get the same C# functionality in D without running out of memory and preferably without using the GC directly?

I'm running Windows Vista 64bit, DMD 2.062 fresh install, compiling with "-m32" flag.

Reply via email to