Skip to content

Severe Memory Leak and OOM Crash with Multi-Threading on Nim 2.2.10 #305

Description

@null-flame

Hello. I have detected a severe memory leak in Prologue when handling high-concurrency traffic under load testing using --threads:on with Nim 2.2.10. The memory accumulates rapidly until it completely fills the RAM and SWAP, freezing the desktop environment, and forcing the Linux kernel to trigger the OOM Killer.

:

Nim Version: 2.2.10

Prologue Version: 0.6.8 (Latest)

OS: Linux fedora

Compiler Flags used: nim c -d:release --mm:orc --opt:speed main.nim (Also tested with -d:danger and --panics:on, with the same leaking result).

Minimal Code Used:

import prologue

proc hello(ctx: Context) {.async.} =
  resp "a"

let app = newApp()
app.get("/", hello)
app.run()

Step-by-Step Chronological Observations (Based on attached screenshots):

Before Test (Idle): The server starts cleanly, spawning 4 threads, consuming a negligible amount of memory.

First Test: I ran bombardier -c 700 -d 20s http://127.0.0.1:8080/. The server handles ~85k RPS beautifully, but memory (RES) suddenly spikes to 4647M (~4.6 GB) per process and never drops back down after the test finishes.

Second Test (Consecutive): Running the exact same bombardier command a second time immediately forces the memory to shoot up to 5440M, and then rapidly climbs to 5523M (~5.5 GB).

The Crash: At this point, the physical RAM (7.30 GB / 7.68 GB) and SWAP (7.68 GB / 7.68 GB) are completely maxed out. The system completely freezes (Gnome-shell starts panicking with "Application Stopped - Device memory is nearly full").

The OOM Kill: Finally, the process is forcefully killed by the OS: [1]  19178 killed  ./main.
Image Image Image Image Image Image

It seems like the HTTP Context or connection/response buffers are not being garbage collected or deallocated by the ORC memory management when crossed over thread boundaries. Could you please look into how thread-local memory or async buffers are handled during high-concurrency connection closures? Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions