Thanks to visit codestin.com
Credit goes to github.com

Skip to content

High Memory Usage of built_value_generator to due memoization + keeping all SerializerSourceClass objects in memory #1288

@knaeckeKami

Description

@knaeckeKami

Hi, it's me again with issues that pop up due to ferry using built_value for serialization of generated graphql code, which can get quite big ;)

built_value_generator keeps a list of SerializerSourceClass for a SerializerSourceLibrary.

So all the SerializerSourceClass objects are kept in memory, and they use memoization to keep e.g. their parsedLibrary and SerializerSourceField fields cached.

This leads to very high memory usage in cases where there are a very high number of serializers.

For reference: gql-dart/ferry#558 (comment)

This can probably be fixed with little changes to the code, e.g. be copying the currently active SerializerSourceClass into a new object which can is not held in a list after the code generation is done
(e.g. sourceClasses.map((clazz) => clazz.rebuild((b) => b)), so the objects with memoized fields are eligible for garbage collection after work is finished for that class.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions