Skip to content

Instantly share code, notes, and snippets.

View textgoeshere's full-sized avatar

Dave Nolan textgoeshere

View GitHub Profile
@wvengen
wvengen / README.md
Last active September 27, 2024 11:07
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@patshaughnessy
patshaughnessy / gist:70519495343412504686
Last active April 28, 2024 01:19
How to Debug Postgres using LLDB on a Mac
This note explains how to build Postgres from source and setup to debug it using LLDB on a Mac. I used this technique to research this article:
http://patshaughnessy.net/2014/10/13/following-a-select-statement-through-postgres-internals
1. Shut down existing postgres if necessary - you don’t want to mess up your existing DB or work :)
$ ps aux | grep postgres
pat 456 0.0 0.0 2503812 828 ?? Ss Sun10AM 0:11.59 postgres: stats collector process
pat 455 0.0 0.0 2649692 2536 ?? Ss Sun10AM 0:05.00 postgres: autovacuum launcher process
pat 454 0.0 0.0 2640476 304 ?? Ss Sun10AM 0:00.74 postgres: wal writer process
pat 453 0.0 0.0 2640476 336 ?? Ss Sun10AM 0:00.76 postgres: writer process
@timcowlishaw
timcowlishaw / monads.rb
Created April 26, 2013 16:19
A Ruby approximation of the Continuation Monad from Haskell, inspired by Dan Piponi's FPComplete tutorial, "The Mother of All Monads": https://www.fpcomplete.com/user/dpiponi/the-mother-of-all-monads
# Inspired by https://www.fpcomplete.com/user/dpiponi/the-mother-of-all-monads, A ruby port of Haskell's continuation monad, using fibers for lazily-evaluated giggles:
#
# For reference, The continuation monad instance definition from haskell:
# instance Monad (Cont r) where
# return a = Cont ($ a)
# m >>= k = Cont $ \c -> runCont m $ \a -> runCont (k a) c
#HI THERE, I AM THE CONTINUATION MONAD
class Cont
def self.unit(x)