You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: guides/source/debugging_rails_applications.md
+1-55Lines changed: 1 addition & 55 deletions
Original file line number
Diff line number
Diff line change
@@ -638,60 +638,7 @@ Debugging Memory Leaks
638
638
639
639
A Ruby application (on Rails or not), can leak memory - either in the Ruby code or at the C code level.
640
640
641
-
In this section, you will learn how to find and fix such leaks by using tools such as BleakHouse and Valgrind.
642
-
643
-
### BleakHouse
644
-
645
-
[BleakHouse](https://github.com/evan/bleak_house/) is a library for finding memory leaks.
646
-
647
-
If a Ruby object does not go out of scope, the Ruby Garbage Collector won't sweep it since it is referenced somewhere. Leaks like this can grow slowly and your application will consume more and more memory, gradually affecting the overall system performance. This tool will help you find leaks on the Ruby heap.
648
-
649
-
To install it run:
650
-
651
-
```bash
652
-
$ gem install bleak_house
653
-
```
654
-
655
-
Then setup your application for profiling. Then add the following at the bottom of config/environment.rb:
656
-
657
-
```ruby
658
-
require'bleak_house'ifENV['BLEAK_HOUSE']
659
-
```
660
-
661
-
Start a server instance with BleakHouse integration:
662
-
663
-
```bash
664
-
$ RAILS_ENV=production BLEAK_HOUSE=1 ruby-bleak-house rails server
665
-
```
666
-
667
-
Make sure to run a couple hundred requests to get better data samples, then press `CTRL-C`. The server will stop and Bleak House will produce a dumpfile in `/tmp`:
668
-
669
-
```
670
-
** BleakHouse: working...
671
-
** BleakHouse: complete
672
-
** Bleakhouse: run 'bleak /tmp/bleak.5979.0.dump' to analyze.
673
-
```
674
-
675
-
To analyze it, just run the listed command. The top 20 leakiest lines will be listed:
This way you can find where your application is leaking memory and fix it.
693
-
694
-
If [BleakHouse](https://github.com/evan/bleak_house/) doesn't report any heap growth but you still have memory growth, you might have a broken C extension, or real leak in the interpreter. In that case, try using Valgrind to investigate further.
641
+
In this section, you will learn how to find and fix such leaks by using tool such as Valgrind.
695
642
696
643
### Valgrind
697
644
@@ -726,4 +673,3 @@ References
726
673
*[Debugging with ruby-debug](http://bashdb.sourceforge.net/ruby-debug.html)
0 commit comments