I'm working on my Quad-Tree for a while now, to generate the landcape. I optimized it pretty nicely so its able to produce new quads in 1 - 2ms.

The problem is that C# slows down when there wasn't create a new quad for a while (while means starting from 500ms).

Here an example:

Node gen; total 106ms noise 69 vert 11 rest Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 2ms noise 0 vert 0 rest 1 Node gen; total 2ms noise 0 vert 0 rest 1 Node gen; total 3ms noise 0 vert 0 rest 2 Node gen; total 4ms noise 2 vert 0 rest 1 Node gen; total 7ms noise 1 vert 0 rest 6 Node gen; total 4ms noise 2 vert 0 rest 2 Node gen; total 37ms noise 1 vert 0 rest 35 Node gen; total 3ms noise 1 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 18ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 22ms noise 16 vert 0 rest 4 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 18ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 18ms noise 15 vert 0 rest 2 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 18ms noise 17 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 18ms noise 16 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 2ms noise 0 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1

As you can see the time for the generation CAN be very fast, but it slows down for no reason

The difficulty of the data to create dosen't change at all.

I know that C# / .NET optimizes parts of code that are 'in heavy use'like the hotspot technology in JVM.

Is there any way to enable it manually? How do you handle it?