Skip to content

[5.8] Fix memory leak in JOIN queries - #28220

Merged
taylorotwell merged 1 commit into
laravel:5.8from
staudenmeir:join
Apr 15, 2019
Merged

[5.8] Fix memory leak in JOIN queries#28220
taylorotwell merged 1 commit into
laravel:5.8from
staudenmeir:join

Conversation

@staudenmeir

Copy link
Copy Markdown
Contributor

Every JoinClause instance receives and stores the parent query. The instance itself then gets stored in the parent query's $joins property. This circular reference causes a memory leak and can be an issue for long-running scripts.

We can fix it by storing the parent query's connection, grammar, processor and class name separately instead of the whole query instance.

The removed $parentQuery property was private, so this shouldn't be a breaking change.

Fixes #28195.

@taylorotwell
taylorotwell merged commit eb9ea35 into laravel:5.8 Apr 15, 2019
@staudenmeir
staudenmeir deleted the join branch April 15, 2019 13:04
@laurencei

Copy link
Copy Markdown
Contributor

Thanks @staudenmeir

@deleugpn

Copy link
Copy Markdown
Contributor

Maybe it would have been better to have these attributes as private as well to make it possible to fix future bugs without breaking change?

@staudenmeir

Copy link
Copy Markdown
Contributor Author

@deleugpn We are only using private properties in very few places (probably not on purpose) and I think we should keep it like that.

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.

[5.8] Memory leak in DB join queries

5 participants