Menu

I got tired of Unity's GC, so I wrote a Zero-Allocation Data-Oriented 2D Engine in pure C# (6000 FPS on empty scene)

Reddit r/csharp·u/Kaverin_Ramil·7 months ago
#ktm7dPTA
#zero#engine#loop#allocated#nativeaot
Reading 0:00
15s threshold

Hey everyone. Just wanted to share a personal milestone. I'm building an RTS engine and wanted to push C# to its absolute limits without relying on heavy third-party frameworks.

My goal was zero garbage collection during the game loop.

Architecture: Strict Data-Oriented Design (DOD). Everything is laid out in unmanaged memory blocks with strict cache-line alignment (64 bytes). The engine loop is currently 100% single-threaded .

Rendering: Custom 2D software renderer using AVX2 intrinsics (supports layering and masks).

Interop: Function pointers ( delegate* unmanaged ) to completely hide unsafe code from the user API.

RAM Usage: A rock-solid 39 MB (as seen in the Task Manager screenshot), which perfectly matches my internal pre-allocated memory pool. No hidden CLR bloat.

To prove the Zero-GC claim, I ran the core loop through BenchmarkDotNet.

The result?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.