Skip to content

Conversation

RobertBoes
Copy link
Contributor

#50973 introduces quite a significant breaking change imho. Job constructors shouldn't perform any work, however this PR now creates job instances for every single job defined in the scheduler.

For a cron that runs every minute and having a lot of scheduled jobs this means every single class is instantiated in memory. This is quite a memory increase for a small developer improvement.

@taylorotwell
Copy link
Member

Sorry - what is the breaking change?

@RobertBoes
Copy link
Contributor Author

Lets say you have this in your routes/console.php:

Schedule::job(Heartbeat::class)->everyFiveMinutes();

Prior to this change the Heartbeat job would only be instantiated when the schedule needs to run that job. With this change it will be instantiated every time, not only when running the scheduler, also when running artisan commands, for web requests etc.

So if your scheduler has lots of jobs scheduled like this those class will now all be instantiated in every single process, consuming memory only to optionally use the displayName method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants