Quick answer: Unreal FPlatformProcess::CreateSharedMemoryRegion handles leaking across editor sessions on Windows? Named shared memory persists if not explicitly closed.

An IPC channel between editor and external tool uses shared memory. Re-running tools without restarting editor accumulates Windows handle objects.

Close Pairing

if (SharedMemory) {
    FPlatformProcess::DestroySharedMemoryRegion(SharedMemory);
    SharedMemory = nullptr;
}

Always destroy on shutdown / re-create. The handle object stays in the kernel otherwise.

Atomic Initialize

Wrap creation/destruction in RAII. The destructor calls Destroy automatically — harder to leak.

Named vs Anonymous

Named shared memory persists across processes; anonymous doesn’t. Choose based on whether you need cross-process discovery.

Handle Counts

Task Manager → Details → Add columns → Handles. Monitor for growth across runs. Sudden jumps indicate leak.

Verifying

Shared memory creation / destruction round-trips without growing handle counts. Re-running tools doesn’t accumulate.

“Shared memory persists if not explicitly destroyed. RAII the lifecycle.”

Track resource handles in a debug list during dev — a periodic check shows leaks before they hit production users.