Who wants to have some fun memory debugging?

Robert Fraser fraserofthenight at gmail.com
Tue May 12 20:37:37 PDT 2009


Simpler version, sans printf:

module leak;

import tango.core.Memory;

struct Data
{
     Data* prev;
     char[4092] something;
}

public void main()
{
     Data* data;
     Data* newData;
     int i;
     while(true)
     {
         for(i = 0; i < 10_000; i++)
         {
             newData = new Data;
             newData.prev = data;
             data = newData;
         }
         data = null;
         newData = null;
         i = 0;
         GC.collect();
     }
}


More information about the Digitalmars-d-learn mailing list