subsonic / SubSonic-3.0

SubSonic 3.0 for the .NET 3.5 Framework
http://subsonic.github.io/
557 stars 210 forks source link

ActiveRecord objects are too fat #249

Open msugakov opened 13 years ago

msugakov commented 13 years ago

Hello I've been trying to implement batch processing operations using SubSonic 3.0.0.4 and ActiveRecord pattern. Loading of 100k objects from database quickly ate 2Gb of RAM. Then I ran a test example:

create table ActiveRecordTest ( Field int )

then

class Program
{
    static void Main(string[] args)
    {
        int N = 10000;
        long before = Process.GetCurrentProcess().WorkingSet64;
        ActiveRecordTest[] array = new ActiveRecordTest[N];
        for (int i = 0; i < N; ++i)
            array[i] = new ActiveRecordTest();
        long after = Process.GetCurrentProcess().WorkingSet64;
        Console.WriteLine("Usage: {0} bytes. Per object (inaccurate): {1} bytes/object", after-before, (after-before)/N);
        return;
    }
}

Results of running this on my system say that there's too big overhead:

Usage: 216301568 bytes. Per object (inaccurate): 21630 bytes/object

I hope that fixing this will improve SubSonic scalability.