You Can Run Ruby in Less Than 150KB of RAM
PicoRuby brings Ruby to microcontrollers with a tiny memory footprint. This quick benchmark compares its RAM usage and execution time against standard CRuby.

Ruby is usually associated with web development, but the Ruby ecosystem has room for much leaner runtimes too. One of them is PicoRuby, a Ruby implementation designed to run on microcontrollers and other highly constrained devices.
According to the official documentation, PicoRuby can run with 128KB of RAM or less. That makes it a very different proposition from standard CRuby and a strong fit for boards where every kilobyte matters.
That smaller footprint comes from deliberate trade-offs. PicoRuby ships with fewer native modules and a simplified garbage collector, favoring minimal memory usage over raw execution speed.
To compare the trade-off in practice, I ran a small Fibonacci benchmark and measured resident memory directly from /proc/self/status on Linux. Because PicoRuby does not include the standard Benchmark gem, the script reads both time and memory usage manually.
def memory_kb
# Direct access to Linux process status
# PicoRuby does not ship with the standard Benchmark gem
File.foreach('/proc/self/status') do |line|
if line.start_with?('VmRSS:')
digits = ''
line.each_char { |char| digits += char if char >= '0' && char <= '9' }
return digits.to_i
end
end
0
end
def fib(number)
return number if number <= 1
fib(number - 1) + fib(number - 2)
end
base = memory_kb
start_time = Time.now
result = fib(30)
duration_ms = ((Time.now - start_time) * 1000).to_i
peak = memory_kb
puts "Result: #{result}"
puts "Execution Time: #{duration_ms}ms"
puts "RAM: #{peak} KB"
puts "Used in Run: #{peak - base} KB"
To keep the comparison reproducible, I ran both interpreters from the same container. The Dockerfile builds PicoRuby from source in one stage, then copies the resulting binary into a slim runtime image alongside the benchmark script.
FROM ruby:3.4-slim AS builder
RUN apt-get update && apt-get install -y \
build-essential \
git \
libssl-dev \
cmake \
&& rm -rf /var/lib/apt/lists/*
RUN gem install rake
RUN git clone --recurse-submodules https://github.com/picoruby/picoruby /picoruby
WORKDIR /picoruby
RUN bundle install && rake
FROM ruby:3.4-slim
RUN apt-get update && apt-get install -y \
build-essential \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /picoruby/bin/picoruby /usr/local/bin/picoruby
COPY benchmark.rb /app/benchmark.rb
CMD ["/bin/sh", "-c", "echo 'CRuby' && ruby /app/benchmark.rb && echo '' && echo 'PicoRuby' && picoruby /app/benchmark.rb"]
The results make the trade-off clear.
$ CRuby
Result: 832040
Execution Time: 52ms
RAM: 13204 KB
Used in Run: 0 KB
$ PicoRuby
Result: 832040
Execution Time: 222ms
RAM: 5044 KB
Used in Run: 64 KB
- CRuby finished in 52ms and used 13,204KB of RAM.
- PicoRuby finished in 222ms and used 5,044KB of RAM.
- During the benchmark run itself, PicoRuby reported an additional 64KB of memory usage.
So while PicoRuby is slower in this benchmark, it cuts the resident memory footprint by roughly 62% compared to standard CRuby. That is the difference that makes Ruby plausible on much smaller devices.
If the goal is developer ergonomics on servers, CRuby is still the obvious choice. But if the goal is embedding Ruby into tiny hardware environments, PicoRuby is a compelling reminder that the Ruby family is much broader than web development alone.
Useful links: