#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require "heap-profiler" require 'fileutils' class SomeCustomStuff end $freed_objects = [+"i am free", +"i am free too"] dir = ARGV.first FileUtils.mkdir_p(dir) FileUtils.rm_rf(Dir[File.join(dir, '*')]) if ARGV[1] == '--empty' HeapProfiler.report(dir) {} else HeapProfiler.report(dir) do $retained_objects = [ +"I am retained", +"I am retained", +"I am retained too", SomeCustomStuff.new, ] "I am a very very long string " * 4 [ +"I am allocated", +"I am allocated too", ] $freed_objects = nil Struct.new("foo".to_sym, :bar) end end