itsgoingd / itsgoingd/clockwork
Clockwork\Request\Log::log will grow its log indefinitely resulting in a memory leak
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 6k
- Forks
- 333
- Avg merge
- 5m
- Merged PRs (30d)
- 1
Description
When handling a lot of events during a longer process, php will run out of memory because all log messages are kept in memory. This is an issue for us as we expect the process to be alive for potentially millions of events.
Our current solution uses a wrapper around clockwork's logger, accesses the public property $messages that's available on clockworks's class and only keep the last 100:
$log = $this->clockwork->log();
if ($log instanceof Log === false) {
throw new \LogicException("Expected log to be of type Clockwork\Request\Log");
}
$log->log($level, $message, $data);
if (count($log->messages) > self::MAX_LOG_SIZE) {
array_shift($log->messages);
}
This works, but maybe it would be worth to consider including this (optional) behaviour out of the box.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Clockwork\Request\Log::log and inspect how messages are retained in the public messages property. Determine how an optional retention limit could fit the existing logging behavior, then verify that long-running processes no longer keep an unbounded log while the default behavior remains clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100