Using Bleakhouse to discover the memory leaks that rails has applied

Source: Internet
Author: User
Tags garbage collection memory usage

While the agility of rails has never been questioned, its performance is often a hot issue.

DTrace is a very useful dynamic framework for analyzing application behavior provided by the Twitter team in the near future. In addition, Evan Weaver has developed a new tool, the Rails plug-in bleakhouse, to handle memory problems. One of the advantages of a dynamic language like Ruby is the ability of the introspect to check the state of your application inside the application, but you should pay more attention when using ObjectSpace (Ruby is garbage-collected object heap probes). Admittedly, Bleakhouse used ObjectSpace to take a snapshot of the rails application in the original version, but Evan Weaver found that ObjectSpace was not quantized: using objectspace would change its state.

Currently, Bleakhouse uses a leak-free C language implementation that uses the heap directly, with the advantage of drawing graphs (swap memory, real memory and combined memory) directly from the actual memory usage and run faster than before.

It can generate a reference chart by controller, action, and class.

Bleakhouse need to use gruff (so also use Rmagick). Because it is implemented in C, it also needs a patched Ruby binary to monitor the application. Once the plugin is installed and the environment is set to the product environment (Production), you can track your application. Finally, you can generate these graphs by running rake.

Figure 1

Figure 2

Figure 3

Bleakhouse reminded Charles Nutter about the fifth suggestion to make Ruby better: Throw objectspace aside, especially when people eventually have to be monitored by patching the VM:

Because of the limitations of Ruby's garbage collection mechanism and threading subsystem, ObjectSpace is harmful to Ruby and should be discarded.

Java has a lot of efficient heap analysis tools, and you might think, where are the Rprobe and Rprofiler for Ruby? I think that as time goes on, new VMs are introduced, and more companies are involved, and such tools will end up in front of people ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.