Memory

Everythings been progressing well however today I started getting the following message output:

GC: 4msec 60144 bytes used, 4236 bytes available
Type 0F (STRING ): 192 bytes
Type 11 (CLASS ): 3252 bytes
Type 12 (VALUETYPE ): 96 bytes
Type 13 (SZARRAY ): 3552 bytes
Type 15 (FREEBLOCK ): 4236 bytes
Type 17 (ASSEMBLY ): 14652 bytes
Type 18 (WEAKCLASS ): 48 bytes
Type 19 (REFLECTION ): 24 bytes
Type 1B (DELEGATE_HEAD ): 324 bytes
Type 1D (OBJECT_TO_EVENT ): 456 bytes
Type 1E (BINARY_BLOB_HEAD ): 5616 bytes
Type 1F (THREAD ): 1920 bytes
Type 20 (SUBTHREAD ): 240 bytes
Type 21 (STACK_FRAME ): 27240 bytes
Type 22 (TIMER_HEAD ): 72 bytes
Type 23 (LOCK_HEAD ): 180 bytes
Type 24 (LOCK_OWNER_HEAD ): 72 bytes
Type 25 (LOCK_REQUEST_HEAD ): 36 bytes
Type 27 (FINALIZER_HEAD ): 264 bytes
Type 31 (IO_PORT ): 324 bytes
Type 34 (APPDOMAIN_HEAD ): 72 bytes
Type 36 (APPDOMAIN_ASSEMBLY ): 1512 bytes
Failed allocation for 164 blocks, 1968 bytes

Now, if 4236 is available, why can’t it allocate 1968?

Because memory is fragmented.

Run Debug.GC(true) to compact your heap

Ahhh of course, thanks I’ll run that through and see what happens.

Hah found out why, I silly endless recursion:

    public void Write(string s)
    {
        byte[] bytes = Encoding.UTF8.GetBytes(s);

        Write(s);
    }