RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Gem that detects possible memory leaks early

Memory leak happens when application tries to load a lot of things to the memory and holds them, so garbadge collector cannot collect objects untill request is fully served. When Ruby virtual machine gets memory from the operating system it won’t be able to return it back because of the page fragmentation, so your monitoring will show that application took a lot and stopped somewhere.

io_monitor tracks the amount of memory consumed when data was loaded from various IO–sources (currently—from the network and the database), compares it with the response size and sends the warning to the logs when the ratio is bigger than expected:

``` class ReportController < ApplicationController include IoToResponsePayloadRatio::Controller

def monthly_transaction_sum sum = Transactions.where(date: Date.current.all_month).sum(&:amount) render json: { sum: sum } end end

Completed 200 OK in 349ms (Views: 2.1ms | ActiveRecord: 38.7ms | ActiveRecord Payload: 866.00 B | Response Payload: 25.00 B | Allocations: 72304)

# ActiveRecord I/O to response payload ratio is 1.8, while threshold is 0.1 ```

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in