Skip to content

Navigation Menu

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

Forms/OptionsResolver Memory Usage #57328

Copy link
Copy link
Open
@rodnaph

Description

@rodnaph
Issue body actions

Symfony version(s) affected

All

Description

In our application we have some large Symfony forms, with many nested collections, which result in hundreds of megabytes of memory usage. We make use of Symfony forms heavily, using events, extensions etc... so I expect there's a lot going on here, but we are looking for ways to reduce this memory usage significantly.

Debugging hasn't led to many obvious problems, just fairly linear increase in memory usage as the form builds.

How to reproduce

The following repository creates a form with a number of nested collections, and reports the memory usage. If the SubLocationType field contains any options then memory usage jumps up.

image

Total memory usage of reproducer, with options added in SubLocationType.

A good deal of this memory usage seems to come from the upload_max_size_message option in the core FormType, the Closure holding onto memory. Overriding this to just return a string dramatically reduces memory usage from OptionsResolver.

image

Memory usage reduced for OptionsResolver, but still quite a lot

Possible Solution

I'm not familiar enough with this component to have any suggested solutions, but it does a bunch of cloning which looks like it may contribute to this (though may be entirely valid functionality).

Additional Context

Any suggestions are appreciated on areas to check, if others have tackled similar problems, etc...

Metadata

Metadata

Assignees

No one assigned

    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.