Skip to content

interceptors.cache causing memory leak after max-age= time #4203

@olessavluk

Description

@olessavluk

Reproducible By

Run using node --expose-gc mem.mjs

https://gist.github.com/olessavluk/8353ba4e76277b137ed2d11b29ed3b6b

Logs & Screenshots

In 1s watch `external` memory NOT leaking
{
  rss: 59.625,
  heapTotal: 17.21875,
  heapUsed: 7.329780578613281,
  external: 3.241048812866211,
  arrayBuffers: 0.1122894287109375
}
Runnig 1000 request sequentially
{
  rss: 429.9375,
  heapTotal: 296.921875,
  heapUsed: 245.27692413330078,
  external: 27.9563570022583,
  arrayBuffers: 18.011958122253418
}
In 5s (after HTTP cache exipire) memory will start leaking
{
  rss: 429.984375,
  heapTotal: 296.921875,
  heapUsed: 245.27588653564453,
  external: 4.026281356811523,
  arrayBuffers: 0.58502197265625
}
Runnig 1000 request sequentially
{
  rss: 387.390625,
  heapTotal: 46.671875,
  heapUsed: 11.3831787109375,
  external: 249.49678134918213,
  arrayBuffers: 233.27368545532227
}
Runnig 1000 request sequentially
{
  rss: 632.515625,
  heapTotal: 49.671875,
  heapUsed: 13.965179443359375,
  external: 472.66299057006836,
  arrayBuffers: 465.9623489379883
}
Runnig 1000 request sequentially
{
  rss: 895.234375,
  heapTotal: 53.671875,
  heapUsed: 15.958457946777344,
  external: 711.3902835845947,
  arrayBuffers: 698.6510124206543
}
^ see how much `external` & `arrayBuffers` increased after second & third run?

Environment

node -v: v20.18.0
uname -a: ... 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6000 arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions