Skip to content

Commit d3719be

Browse files
committed
Updated and added clarification to batchSize behavior
1 parent 19e93dc commit d3719be

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/EventLogExpert.Eventing/Readers/EventLogReader.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ public void Dispose()
2626
GC.SuppressFinalize(this);
2727
}
2828

29-
// BatchSize can cause some weird behavior if it's too large
30-
// Tested 1024 which returned failure way too early, 512 caused weird memory bloat
31-
// and there was barely a noticeable speed difference between 64 and 512
32-
public bool TryGetEvents(out EventRecord[] events, int batchSize = 64)
29+
// Pre-Windows 11, a batch being returned can be maximum of (2 MB of data, batchSize count of events).
30+
// If the requested number of events in batchSize exceeded 2 MB, the call failed.
31+
// With a maximum event size of 64 KB, the maximum batchSize that won't exceed the maximum buffer
32+
// size is 30 (32 minus some overhead; refer to MS-EVEN6 for details).
33+
// Windows 11 and later will stop filling out the buffer when the maximum size is reached, regardless
34+
// of whether the requested batchSize was reached (but it will not exceed the requested count).
35+
public bool TryGetEvents(out EventRecord[] events, int batchSize = 30)
3336
{
3437
var buffer = new IntPtr[batchSize];
3538
int count = 0;

0 commit comments

Comments
 (0)