Skip to content

memory leak #797

@JakobJingleheimer

Description

@JakobJingleheimer

After switching to ky (I've been a fan and using it for years—thank you!), we initially saw a nice reduction in memory usage in our (fastify) RESTful server but it started to steeply increase.

Here is memory utilisation charted over ~4 months: ~1 month before switching to ky, ~2 months with ky, and ~1 week after switching away from ky (to undici request).

Prior to switching to ky, you can see memory usage is fairly flat (albeit higher overall).

When ky was used between 12 September and 17 November, you can see about a dozen peaks (where utilisation doubles over ~1 week) followed by sharp drops (server restarted or a fresh deploy).

After switching away from ky, you can see memory usage is flat again (it's been flat for the past ~3 weeks, but only the first ~1 week is shown in the chart).

We tried to track down the specific cause (@Ceres6 did quite a lot of heap inspection), and it seems to be related to unclosed streams ky creates for KyResponse and HTTPError (which might just be a knock-on effect due to the KyResponse that HTTPError contains). Manually closing streams on KyResponse.body seemed to help? If that's expected and necessary to do on every response and every error, that burden is much too high 😬

P.S. Sorry this isn't more helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions