Skip to content

Response strings and closures objects leak with http.Agent enabled (Memory Leak) #9530

Closed
@snow01

Description

@snow01
  • Version: v6.9.1
  • Platform: Linux ip-172-31-46-151 4.4.11-23.53.amzn1.x86_64 deps: update openssl to 1.0.1j #1 SMP Wed Jun 1 22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: Http(s) Agent

http.Agent based sockets pool is leading to memory leaks. With http.Agent enabled, both response strings and response handlers (closures) are not getting released so quickly -- all these objects and closures are getting promoted to old generation. Even on a normal load of 2-3 requests per second, garbage collection is not able to free these promoted objects an closures, application's memory usage reaches to 1GB in just 10-12 hours of run -- eventually application crashes due to out of memory.

Pool settings are normal --

new http.Agent({
        keepAlive: true,
        maxSockets: 10,
        maxFreeSockets: 5,
        keepAliveMsecs: 5000
    })

I have done comparison of heap snapshots at various time points to reach to this conclusion. I have even verified that with default agent settings (that is http.globalAgent), I do not see any such behaviour - application memory remains consistent at ~90-95Mb

Below are screenshots from chrome developer tools for various scenarios --

  1. With http.Agent enabled, strings delta is 10 Mb. From Retainers tab it is clear that these objects are from http requests.

screenshot 2016-11-09 22 38 46

  1. With http.Agent enabled, closures delta is 0.5 Mb. From Retainers tab it is clear that these closures are from http requests.

screenshot 2016-11-09 22 39 10

  1. Without http.Agent, there is no positive delta for strings and closures

screenshot 2016-11-09 22 39 26

Please guide how can I help quick resolution of this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions