Skip to content

EventLogService.SearchAsync: unbounded result list — OOM on large event logs #253

@Christophe-Rogiers

Description

@Christophe-Rogiers

Description

EventLogService.cs lines 74–99 collect all matching events into a List<EventLogEntry> with no upper bound.

Code

var results = new List<EventLogEntry>();

foreach (var evt in records)
{
    token.ThrowIfCancellationRequested();
    // ... filtering ...
    results.Add(evt);  // unbounded
}

return results.OrderByDescending(r => r.Time).ToList();

Scenario

User searches for "Error" on a server with years of event logs → hundreds of thousands of entries loaded into memory → OutOfMemoryException crashes the Manager application.

Suggested Fix

Add a maxResults cap:

const int MaxResults = 10_000;

foreach (var evt in records)
{
    token.ThrowIfCancellationRequested();
    // ... filtering ...
    results.Add(evt);

    if (results.Count >= MaxResults)
        break;
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions