Skip to content

Excessive memory consumption with large array literals #23367

Description

@WalterBright

The declaration of ArrayLiteralExp has an array of pointers pointing to each element of the array. If the pointer at a particular array index is null, then the basis field is used instead. This saves a great deal of memory for carrying around large array literals, that are mostly the same value (like 0).

Unfortunately, the function copyLiteralArray() in ctfeexpr.d fills the array with copies of basis. This can result in a great deal of memory consumption with large arrays.

The fix should be not allocating a copy if the basis has the same value in it.

This was brought up by Luis Ferreira of Weka.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions