Skip to content

Unnecessary Boxing and Increased Memory Usage #665

Description

@zqll4

After analyzing the memory usage, it was observed that the code causes boxing, resulting in unnecessary objects being created, which leads to increased memory consumption.

class IntFieldMutator implements UniFieldMutator {
    public int read(Component c, Field f) {
        try {
            return (Integer)f.get(c);
        } catch (ReflectionException var4) {
            ReflectionException e = var4;
            throw new RuntimeException(e);
        }
    }
}

The casting to Integer causes an unnecessary object creation when the method returns an int. This can be avoided by directly handling primitive types, which would help reduce memory overhead.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions