On Dec 14, 2011, at 2:04 AM, Charles Oliver Nutter wrote:

> On Tue, Dec 13, 2011 at 8:03 PM, Chuck Remes <cremes.devlist / mac.com> wrote:
>>> Three million new classes created. I'm sure it's singleton somewhere,
>>> but that's often a big perf sink...not necessarily because it impacts
>>> straight-line code a lot, but because a class object is a nontrivial
>>> thing to be creating three million of.
>> 
>> Is there a way for JRuby to output more detail on those classes? For example, can it tell me how many of each class type have been allocated? If so, I could use that information to figure out the critical path and try to reduce the amount of class creation there.
> ...
>> Also, I'm not certain what you mean by "I'm sure it's singleton somewhere." I know what a singleton is, but I don't understand your use of it in this context. Elaborate, please.
> 
> Actually, it may not be a singleton object/class, now that I think
> about it. Someone, somewhere is doing a Class.new {  } (or similar) in
> critical path code.

Okay, so I should look for lines where I execute "Class.new {}" in my code. Off the top of my head, it is *rare* that I call Class.new directly; it's almost always via an actual class constant name.

>> I'll take a shot at reducing my object allocation. More information on how many of each type of object is being allocated would be a wonderful statistic to have. Also, if there were a way to trace that allocation back to a particular file and line number (for those cases where the same object is allocated in multiple places), that would be a killer profiling feature. <hint, hint>
> 
> Indeed it would. Luckily, the JVM already provides it.
> [snip]
> If you find this information useful, perhaps you can reformat it for a
> JRuby wiki page :)

I find it *very* useful and I *will* add it to the wiki. Thanks for taking the time to post this!

cr