IT lexicon › Programming › Safepoint

Safepoint

Programming På svenska → Updated: 2026-11-05

A point in compiled code where a thread can be stopped and the garbage collector knows exactly where every object reference lives.

Optimised code keeps pointers in registers and in stack slots that only the compiler knows about. For a moving collector to update them, it has to know where they are, and that information — stack maps — is only produced for selected points. The JIT therefore plants cheap checks on loop back-edges and at method returns, where the thread asks whether anyone wants it to stop. For years HotSpot did this with a read from a memory page that got protected when it was time; JDK 10 added thread-local handshakes.

The weak spot is time to safepoint. Every thread has to reach one before the pause can begin, and HotSpot stripped the checks out of counted integer loops. A single long loop of that kind could keep the whole JVM waiting for seconds, while the GC log reported a short pause.

← Back to the lexicon