Skip to content

Instantly share code, notes, and snippets.

@gavingmiller
Created May 12, 2015 19:57
Show Gist options
  • Save gavingmiller/ba45f154d6ed341e17d9 to your computer and use it in GitHub Desktop.
Save gavingmiller/ba45f154d6ed341e17d9 to your computer and use it in GitHub Desktop.
Dumping Memory from Heroku to S3
def dump_memory
GC.start
time = DateTime.now.strftime('%-l%M')
path = Rails.root.join("tmp/ruby-heap.#{time}.dump")
io = File.open(path, "w")
ObjectSpace.dump_all(output: io)
io.close
bucket = $s3.buckets['mah-bucket']
obj = bucket.objects[time]
obj.write(IO.binread(path))
render text: "success - #{time}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment