mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-15 02:58:30 +00:00
Fix memory leak in EventListener where completed/failed tasks were never fully removed from the execution_spans dictionary. Instead of removing entries, the code was setting them to None, causing task objects to remain referenced indefinitely and preventing garbage collection. Changes: - Replace 'self.execution_spans[source] = None' with 'self.execution_spans.pop(source, None)' in both TaskCompletedEvent and TaskFailedEvent handlers - Add comprehensive tests to verify execution_spans cleanup behavior This fixes unbounded memory growth in long-running processes or systems executing many tasks. Fixes #4222 Co-Authored-By: João <joao@crewai.com>