I am relying on several of the Neo4j::Rails::Model features so I'm hoping to solve this in that context before resorting to using neo4j-core.
I went ahead and used jmap to get a sense of what was using up the memory. I'm a bit outside of my knowledge on this, so consider this a naive first pass.
At the moment the memory leak is occurring, the full list looks like this:
num #instances #bytes class name
----------------------------------------------
1: 628997 326402088 [B
2: 574226 22969040 org.jruby.util.ByteList
3: 510731 20429240 org.jruby.RubyHash$RubyHashEntry
4: 560446 17934272 org.jruby.RubyString
5: 63654 13124856 [C
6: 71988 10956824 <constMethodKlass>
7: 71988 9801360 <methodKlass>
8: 9748 8879536 <instanceKlassKlass>
9: 9748 8331112 <constantPoolKlass>
10: 115582 7399240 [Lorg.jruby.RubyHash$RubyHashEntry;
11: 242891 6841080 [Ljava.lang.Object;
12: 115578 6472368 org.jruby.RubyHash
13: 102662 5696312 <symbolKlass>
14: 9213 4921416 <constantPoolCacheKlass>
15: 195806 4699344 java.lang.Long
16: 87162 2789184 org.jruby.RubyFixnum
17: 5425 2641392 <methodDataKlass>
Grepping out the jRuby objects (with the reify option passed):
146: 2407 57768 rubyobj.Neo4j.Core.Index.LuceneQuery
225: 560 13440 rubyobj.Person
229: 545 13080 rubyobj.Gem.Version
233: 511 12264 rubyobj.Gem.Requirement
256: 383 9192 rubyobj.Gem.Dependency
390: 122 2928 rubyobj.URI.HTTPS
392: 121 2904 rubyobj.Net.HTTP
394: 121 2904 rubyobj.Net.HTTPOK
395: 121 2904 rubyobj.OAuth.Consumer
397: 121 2904 rubyobj.Neo4j.Rails.Relationships.Storage
398: 121 2904 rubyobj.DateTime
399: 121 2904 rubyobj.OAuth.AccessToken
400: 120 2880 rubyobj.ActiveModel.Errors
404: 114 2736 rubyobj.Rails.Initializable.Initializer
467: 78 1872 rubyobj.Monitor
476: 73 1752 rubyobj.Rake.Task
493: 63 1512 rubyobj.Gem.Specification
505: 56 1344 rubyobj.Bundler.LazySpecification
702: 22 528 rubyobj.Mime.Type
The Ruby objects look reasonable. The biggest chunk of memory is obviously being used by "[B" but I don't know what that means.
If you have any guesses about what is causing the memory leak I think that's the primary issue at the moment.
BTW, if I don't include the Neo4j::Rails::Model.close_lucene_connections call after each import, those objects do start to run away in jmap, so that was definitely a problem and one which was addressed with that call. I'd expect the Rails model to close those connections for me. Also, for that pattern of "find in index, or create" I'd expect "get_or_create" to work; some kind of more intuitive Unique Factory API at this level would be good.
Dave