Skip to content

Instantly share code, notes, and snippets.

View mtparet's full-sized avatar

Matthieu Paret mtparet

View GitHub Profile
@wvengen
wvengen / README.md
Last active March 25, 2024 07:53
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

@dimus
dimus / damerau_levenshtein distance for ruby
Created July 14, 2009 15:48
Damerau-Levenshtein distance for ruby in C
#!/usr/bin/env ruby1.9
# encoding: UTF-8
require 'rubygems'
require 'inline'
require 'time'
class DamerauLevenshtein
def distance(str1, str2, block_size=2, max_distance=10)
res = distance_utf(str1.unpack("U*"), str2.unpack("U*"), block_size, max_distance)
(res > max_distance) ? nil : res