edgurgel / httpoison

Yet Another HTTP client for Elixir powered by hackney
https://hex.pm/packages/httpoison
MIT License
2.23k stars 339 forks source link

FIX: Memory leak: HTTPoison.Base.transformer #456

Closed Zarathustra2 closed 2 years ago

Zarathustra2 commented 2 years ago

Previously Process.monitor had been called in every recursion for the target even though we only need to call it only once.

I observed that on production when using httpoison to consume server sent events. Noticed in the observer_cli:

httpoison_leak

I am currently using the PR code in production and it fixed the issue. Now also the blacked out processes to which I stream the server sent events ( so they are the target which has been monitored via Process.monitor(target) in the tranformer ) have a memory footprint of 8MB.

edgurgel commented 2 years ago

Thanks! Nice catch!