Latest in branch 2.2
2.2.10
Released 28 Mar 2018
(8 years ago)
SoftwareRuby
Version2.2
Status
End of life
Initial release2.2.0
25 Dec 2014
(11 years ago)
Latest release2.2.10
28 Mar 2018
(8 years ago)
End of bug fixes28 Mar 2017
(Ended 9 years ago)
End of life31 Mar 2018
(Ended 8 years ago)
Release notes https://ruby-lang.org/en/news/2018/03/28/ruby-2-2-10-released/
Source codehttps://github.com/ruby/ruby/tree/v2_2_10
Documentationhttps://ruby-doc.org
Downloadhttps://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.10.tar.gz
Ruby 2.2 ReleasesView full list

What Is New in Ruby 2.2

Ruby 2.2 brings significant garbage collection improvements, new methods, and incremental enhancements across the standard library. This release focuses on optimizing memory usage and providing more powerful tools for developers.

Category Key Changes
Garbage Collection Incremental GC, Symbol GC
New Methods Binding#receiver, Module#prepend, String#unicode_normalize
Libraries Psych, RDoc, RubyGems updates
Performance Fork speed improvement, malloc/calloc optimizations
Deprecations DL, ext/tk, pre-1.9 proc arg handling

How did garbage collection get smarter in Ruby 2.2?

The headline feature is the new Incremental Garbage Collector. Instead of stopping your entire application for a full GC cycle, the work is broken into smaller pieces and interleaved with program execution. This drastically reduces pause times, making applications feel more responsive.

Ruby 2.2 also introduced Symbol GC. Previously, symbols were never garbage collected, which was a potential memory leak vector for long-running apps that created symbols dynamically. Now, symbols created from strings can be collected, which is a big win for security and memory usage.

What new methods should I start using?

Binding#receiver is a handy addition that returns the object that owns the binding's context. This is useful for metaprogramming and debugging, giving you direct access to the receiver object.

Module#prepend is now officially supported after being experimental. It allows you to insert a module in front of a class in the ancestor chain, which is more powerful than include for certain kinds of method wrapping and refinement.

The new String#unicode_normalize method and its bang variant provide built-in Unicode normalization, making it easier to handle different character representations without external gems.

Which libraries received major updates?

Psych

The YAML parser Psych was updated to libyaml 0.1.6. This update includes various bug fixes and improves the overall stability and correctness of YAML parsing in Ruby.

RDoc

RDoc got a significant update to version 4.2.0. It includes numerous improvements for generating documentation, with better parsing and formatting capabilities.

RubyGems

RubyGems was updated to version 2.4.5, which includes various bug fixes and performance improvements for managing gem dependencies and installations.

Were there any performance wins beyond GC?

Yes, the process of forking became much faster on systems with copy-on-write friendly malloc implementations. This is a major benefit for web servers like Unicorn that rely heavily forking worker processes.

Ruby's internal memory allocation was optimized to use malloc/calloc more efficiently, reducing memory overhead. These low-level optimizations contribute to overall better memory footprint and performance.

What was deprecated or removed?

The DL standard library for interfacing with C libraries was deprecated in favor of the newer Fiddle library, which provides a more maintainable and cleaner API for the same functionality.

Support for the Tk graphical user interface toolkit (ext/tk) was moved to a separate gem, reducing the size of the core Ruby distribution for users who don't need GUI capabilities.

The pre-Ruby 1.9 style of Proc invocation where a single array argument would be automatically expanded was finally removed, solidifying the modern behavior.

FAQ

Does the incremental GC require any code changes?
No, it's completely transparent. Your existing code automatically benefits from reduced garbage collection pause times without any modifications.

Why is Symbol GC such a big deal?
Before 2.2, dynamically created symbols (like from params in a web app) would never be freed, creating a memory leak attack vector. Now they can be collected, making apps more secure.

When should I use Module#prepend over include?
Use prepend when you need to override methods in a way that still allows calling the original method with super. It inserts the module before the class in the ancestor chain.

What's the practical benefit of faster forking?
Web servers that use forking models (like Unicorn) can restart workers much quicker, leading to better deployment speed and responsiveness during traffic spikes.

Is it safe to upgrade from Ruby 2.1 to 2.2?
Generally yes, as it maintains backward compatibility. The main things to check are the deprecated DL library if you use it, and ensuring any C extensions are compatible with the new GC changes.

Releases In Branch 2.2

VersionRelease date
2.2.1028 Mar 2018
(8 years ago)
2.2.914 Dec 2017
(8 years ago)
2.2.814 Sep 2017
(8 years ago)
2.2.728 Mar 2017
(9 years ago)
2.2.615 Nov 2016
(9 years ago)
2.2.526 Apr 2016
(10 years ago)
2.2.416 Dec 2015
(10 years ago)
2.2.318 Aug 2015
(10 years ago)
2.2.213 Apr 2015
(11 years ago)
2.2.103 Mar 2015
(11 years ago)
2.2.025 Dec 2014
(11 years ago)
2.2.0-rc118 Dec 2014
(11 years ago)
2.2.0-preview228 Nov 2014
(11 years ago)
2.2.0-preview118 Sep 2014
(11 years ago)