Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method · added in Ruby 3.3

Process.warmup

() -> bool
Process.warmup → true

Notify the Ruby virtual machine that the boot sequence is finished, and that now is a good time to optimize the application. This is useful for long running applications.

This method is expected to be called at the end of the application boot. If the application is deployed using a pre-forking model, Process.warmup should be called in the original process before the first fork.

The actual optimizations performed are entirely implementation specific and may change in the future without notice.

On CRuby, Process.warmup:

  • Performs a major GC.

  • Compacts the heap.

  • Promotes all surviving objects to the old generation.

  • Precomputes the coderange of all strings.

  • Frees all empty heap pages and increments the allocatable pages counter by the number of pages freed.

  • Invoke malloc_trim if available to free empty malloc pages.

  • Eagerly loads the error_highlight, did_you_mean, and syntax_suggest gems, which are otherwise loaded lazily on the first error display.

Ruby version changes

  1. 3.3
    • New Process.warmup method that notify the Ruby virtual machine that the boot sequence is finished, and that now is a good time to optimize the application. This is useful for long-running applications. The actual optimizations performed are entirely implementation-specific and may change in the future without notice. [Feature #18885]

See also .waitpid2 .waitpid also in 4.0 · 3.4 · 3.3