Created
August 17, 2010 16:08
-
-
Save djsun/530570 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mongo' | |
class MongoLeakFinder | |
def initialize | |
db = Mongo::Connection.new.db("cgp") | |
@coll = db.collection("records") | |
@coll.create_index("n", :unique => true) | |
end | |
MAX = 1_000_000_000 | |
def run | |
n = 0 | |
loop do | |
puts "%09i" % n | |
@coll.find("n" => n) | |
n += 1 | |
n = 0 if n >= MAX | |
end | |
end | |
end |
On my system, this code does not seem to have any space leak. Real memory usage varies between 22.1 MB and 23.1 MB. (Garbage collection apparently kicks in at 23.1 and brings it down to 22.1.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: I already have objects in the cgp database with the "n" key.