ForzaElixir / rollbax

Exception tracking and logging from Elixir to Rollbar
https://hexdocs.pm/rollbax
ISC License
243 stars 52 forks source link

Could Rollbax cause a memory leak in my application? #120

Open ryanzidago opened 3 years ago

ryanzidago commented 3 years ago

Hi all,

I'm having some trouble identifying why do I have a memory leak in my application. You can find more info in this Elixir Forum post. Otherwise, as a TLDR:

I have a process error_logger that keeps accumulating data. When I look into the process' state I see the following:

{items,{"Installed handlers",
        [{handler,'Elixir.Rollbax.Logger',false,
                  #{'__struct__' => 'Elixir.Rollbax.Logger',
                    reporters => ['Elixir.Rollbax.Reporter.Standard']},
                  false}]}}

This is why I think Rollbax may be causing memory leak in my application.

Elixir version:

1.11.2

Erlang version:

23.0.3

Rollbax version:

  "rollbax": {:hex, :rollbax, "0.11.0", "9557935d09d154c8775fa4efc709bfacbb73f20c58a3ced31dea2a74dd6e25de", [:mix], [{:hackney, "~> 1.1", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "a74318b175aae4bdddcc1ecfdf38755df3d8143c9902b1bfd19507ac9901062d"},

Do you know how does Rollbax uses the error_logger? Does it seem plausible that Rollbax is causing a memory leak and if so, why? :thinking:

ryanzidago commented 3 years ago

After deactivating Rollbax from my app, the memory leak disapeared. So it seems that there is strong evidence that the memory leak is caused by Rollbax. This relates to what someone told me in my post.

However, I'd like to keep Rollbax around as all of our other applications use it without any trouble and Rollbar is quite convenient :smiley:

qcam commented 3 years ago

Hey @ryanzidago, I could help to take a look if you would be able to come up with a working repo to reproduce your observation.

ryanzidago commented 3 years ago

Hey @ryanzidago, I could help to take a look if you would be able to come up with a working repo to reproduce your observation.

Thanks for offering your help :pray: Unfortunately, I can't even reproduce the error on staging, let alone locally.

I was looking more fore an educated guess :sweat_smile:

ryanzidago commented 3 years ago

Disabling the enable_crash_reports "fixed" the issue because it didn't start the error_logger process.

error_logger is actually quite known to cause memory leaks :thinking: There's a whole section about this process in the Erlang in Anger book.