Skip to content

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

Closed
soyuka wants to merge 1 commit intoapi-platform:3.4from
soyuka:fix/paginator-worker-mode
Closed

fix(doctrine): memory leak when using the iterator mongodb#6878
soyuka wants to merge 1 commit intoapi-platform:3.4from
soyuka:fix/paginator-worker-mode

Conversation

@soyuka
Copy link
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
Member Author

soyuka commented Dec 19, 2024

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

@GromNaN
Copy link
Copy Markdown
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.

@GromNaN
Copy link
Copy Markdown
Contributor

GromNaN commented Feb 2, 2025

This PR can be closed, as #6912 did the same.

@soyuka soyuka closed this Feb 3, 2025
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