Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/TraceEvent/TraceEventSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2509,8 +2509,14 @@ private void EnsureStarted(TraceEventNativeMethods.EVENT_TRACE_PROPERTIES* prope
else
{
properties->LogFileMode |= TraceEventNativeMethods.EVENT_TRACE_BUFFERING_MODE;
// Size the in-memory circular buffer purely by the number of buffers, leaving BufferSize at the
// per-buffer quantum set above (m_BufferQuantumKB). MinimumBuffers is intentionally computed against
// that same quantum so that (MinimumBuffers * BufferSize) == m_CircularBufferMB megabytes.
// Do NOT set BufferSize to m_CircularBufferMB here: BufferSize is a per-buffer size in KB, so treating
// a megabyte value as KB makes each buffer exceed ETW's maximum buffer size. On some systems that
// causes the subsequent KernelTraceControl merge (CreateMergedTraceFile) to fail (e.g. 0x80280012),
// and inflates the requested memory quadratically.
properties->MinimumBuffers = (uint)(m_CircularBufferMB * 1024 / m_BufferQuantumKB);
properties->BufferSize = (uint)m_CircularBufferMB;
}
properties->LogFileNameOffset = 0;
}
Expand Down