Skip to content

Instantly share code, notes, and snippets.

@shageman
Created January 13, 2011 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shageman/778291 to your computer and use it in GitHub Desktop.
Save shageman/778291 to your computer and use it in GitHub Desktop.
Memory (and classes) leak in neo4jrb
#!/usr/bin/env ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m
# Profile these different versions (e.g. with VisualVM)
# jruby 1.5.6: watch the number of classes rise with every iteration. Eventually PermGen space will be exhausted.
# jruby 1.6.0.rc1: the classes get garbage collected regularly.
require "rubygems"
require 'neo4j' #1.0.0.beta.26
class Node
include Neo4j::NodeMixin
property :user_id
has_n(:contacts)
end
node1 = nil
Neo4j::Transaction.run do
node1 = Node.new(:user_id => 1)
end
for node_id in 2..100000
Neo4j::Transaction.run do
node = Node.new(:user_id => node_id)
node.contacts << node1
puts node.contacts.include?(node1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment