Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(doctrine): memory leak when using the iterator mongodb #6878

Open
wants to merge 1 commit into
base: 3.4
Choose a base branch
from

Conversation

soyuka
Copy link
Member

@soyuka soyuka commented Dec 18, 2024

No description provided.

@soyuka soyuka changed the title fix(doctrine): memory leak when using the iterator fix(doctrine): memory leak when using the iterator mongodb Dec 18, 2024
@@ -38,18 +38,23 @@ final class Paginator implements \IteratorAggregate, PaginatorInterface, HasNext

private readonly int $totalItems;

private readonly int $count;

public function __construct(private readonly Iterator $mongoDbOdmIterator, private readonly UnitOfWork $unitOfWork, private readonly string $resourceClass, private readonly array $pipeline)
Copy link
Contributor

@GromNaN GromNaN Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can forget it.

Suggested change
public function __construct(private readonly Iterator $mongoDbOdmIterator, private readonly UnitOfWork $unitOfWork, private readonly string $resourceClass, private readonly array $pipeline)
public function __construct(Iterator $mongoDbOdmIterator, private readonly UnitOfWork $unitOfWork, private readonly string $resourceClass, private readonly array $pipeline)

@soyuka
Copy link
Member Author

soyuka commented Dec 19, 2024

Should've been fixed by doctrine/mongodb-odm#2709 ?

@GromNaN
Copy link
Contributor

GromNaN commented Dec 19, 2024

I think this is still a relevant change. It frees up the cursor and its stacked iterators, from the memory, to keep only the results as an array, before starting another memory-consuming job: hydration.

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