Skip to content

Memory optimization #4971

@magicprinc

Description

@magicprinc

There is a memory optimization that can be used in Vert.x in several places.
For example, here:
io.vertx.core.impl.VertxImpl.InternalTimerHandler
private final AtomicBoolean disposed = new AtomicBoolean();
AtomicBoolean is quite a heavy object (many times bigger than volatile boolean)
It can be replaced with VarHandle. The VarHandle has all the same operations, but it is a static field member of a class and in object there is only a volatile byte or int field. You can see this technic in JDK 
java.util.concurrent.FutureTask#set

Replacing Atomic* with VarHandle and volatile in libraries makes sense.
It dramatically reduces the memory footprint without disadvantages.

I could make a PR for InternalTimerHandler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions