Skip to content

Instantly share code, notes, and snippets.

@cddr
Last active December 16, 2015 17:29
Show Gist options
  • Save cddr/5470822 to your computer and use it in GitHub Desktop.
Save cddr/5470822 to your computer and use it in GitHub Desktop.
Finding a memory leak in ruby2/rails4
#You Only Leak Once
# Install valgrind using one of the following
brew install valgrind
sudo apt-get install vagrind
# make sure valgrind is enabled in your ruby build
CONFIGURE_OPTS="--with-valgrind" rbenv install 2.0.0-p0
# control test (should not show any memory leaks)
valgrind --leak-check=full -v ruby -e "puts 'yolo'"
# one of our unit tests (takes a lot longer than running the test normally)
valgrind --trace-children=yes --leak-check=full -v ruby -Ilib:test test/unit/publisher_test.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment