Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Better memory releasing on kernel shutdown #13448

Copy link
Copy link
Closed
@stof

Description

@stof
Issue body actions

currently, shutting down the kernel (between tests generally) is doing several steps:

  • running the shutdown logic of each bundle
  • removing the container reference from each bundle
  • removing the container reference from the kernel

At this point, we consider that the container is meant to be out of scope.

However, as soon as a service is aware of the container, we get a cyclic object graph because of the service reference hold by the container. This means that none of the services will be garbage collected by the refcount.

I suggest adding a clear() method on the container (and a ClearableContainerInterface used by the kernel to know whether it can clear the container) which would clear the list of service instances ($this->services, $this->scopedServices and $this->scopeStacks). this would remove the reference hold by the container itself, meaning that most services will then be able to be collected by the refcount (cyclic references inside the service object graph should be rare, given the only way to achieve them is to add a reference at runtime. the container prevents having cyclic service references). And the container itself will then be collected once all container aware services are.

what do you think about that @fabpot and @nicolas-grekas ?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.