
Security News
NIST Under Federal Audit for NVD Processing Backlog and Delays
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Sheap is a library for interactively exploring Ruby Heap dumps. Sheap contains a command-line tool and a library for use in IRB.
Some examples of things you can do with Sheap:
Why Ruby heap dumps, briefly:
You can gem install sheap
to get sheap as a library and command line tool. You can also download lib/sheap.rb
to a remote server and require it as a standalone file from IRB.
Using the command line will open an IRB session with the heap loaded. You can then use the $diff
, $before
, and $after
variable to explore the heap.
$ sheap [HEAP_BEFORE.dump] [HEAP_AFTER.dump]
To use directly with IRB:
# $ irb
require './lib/sheap'
# Create a diff of two heap dumps
$diff = Sheap::Diff.new('tmp/heap_before.dump', 'tmp/heap_after.dump')
# Find all retained objects and count by type
$diff.retained.map(&:type_str).tally.sort_by(&:last)
# => [["DATA", 1], ["FILE", 1], ["IMEMO", 4], ["STRING", 4], ["ARRAY", 10000]]
# Find the 4 largest arrays in the 'after' heap dump
>> $diff.after.arrays.sort_by(&:length).last(5)
# =>
# [#<ARRAY 0x100ec0440 (512 refs)>,
# #<ARRAY 0x100ec9270 (512 refs)>,
# #<ARRAY 0x100f4b450 (512 refs)>,
# #<ARRAY 0x11bc6d5b0 (512 refs)>,
# #<ARRAY 0x11c137960 (10000 refs)>]
# Grab and examine just the largest array
large_arr = $diff.after.arrays.max_by(&:length)
# =>
# #<ARRAY 0x1023effc8
# type="ARRAY",
# shape_id=0,
# slot_size=40,
# class=#<CLASS 0x100e43350 Array (252 refs)>,
# length=10000,
# references=(10000 refs),
# memsize=89712,
# flags=wb_protected>
# Is it old?
large_arr.old?
# => false
# Find the first of its references
large_arr.references.first
# =>
# #<ARRAY 0x11c13fdb8
# type="ARRAY",
# shape_id=0,
# slot_size=40,
# class=#<CLASS 0x100e43350 Array (252 refs)>,
# length=0,
# embedded=true,
# memsize=40,
# flags=wb_protected>
# Reference that same object by address
$diff.after.at("0x11c13fdb8")
# =>
# #<ARRAY 0x11c13fdb8
# type="ARRAY",
# ...
# Show that object's path back to the root of the heap
$diff.after.find_path($diff.after.at("0x11c13fdb8"))
# => [#<ROOT global_tbl (13 refs)>, #<ARRAY 0x1023effc8 (10000 refs)>, #<ARRAY 0x11c13fdb8>]
Sheap on its own will not generate heap dumps for you. Some options for generating heap dumps:
ObjectSpace.dump_all(output: open("tmp/snapshot1.dump", "w"))
bundle exec derailed exec perf:heap_diff
produces 3 generations of heap dumps.After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/jhawthorn/sheap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Sheap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that sheap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.
Security News
TypeScript Native Previews offers a 10x faster Go-based compiler, now available on npm for public testing with early editor and language support.