问题
Is there a way to query the ram footprint of a specific object in JRuby?
回答1:
Have you heard about jmap, jhat, and visualvm?
jmap outputs the object memory maps / heap memory details for the given Java process.
jhat is a heap analysis tool that lets you create a Java heap dump, and then lets you query it using a SQL-like language to get more detail.
visualvm is yet another Java tool for viewing details about a Java applications as they are running in the JVM.
I found this post from Charles Nutter to be very helpful in getting me started in JRuby profiling and memory inspection.
来源:https://stackoverflow.com/questions/8327049/how-to-get-the-ram-footprint-of-a-specific-object-in-jruby