Skip to content

Optimize read-only collectionsΒ #3070

@dovchinnikov

Description

@dovchinnikov

In Toolbox we parse HUGE json. Once parsed, it allocates too much memory. Right now, the default ArrayList is used, it allocates 10 elements, but most of the time it has zero or one element only. We have ~100k such arrays visible in the memory dump.

Suggestion

For read-only collections:

  • use empty singletons for empty collections (e.g., EmptyList)
  • use singleton implementations (e.g., SingletonMap) for single-element collections.
  • trim collections with >1 elements.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions