dom96 / jester

A sinatra-like web framework for Nim.
MIT License
1.57k stars 120 forks source link

Suspecting of memory leak in Jester with --gc:arc #271

Closed BLeAm closed 3 years ago

BLeAm commented 3 years ago

I've tested a simple "Hello World" and compiled it with these parameters:

--define:release
--define:danger
--define:useMalloc
--define:useStdLib
--gc:arc

then benchmarked it with wrk like this:

wrk -t2 -c5 -d20s --timeout 2s http://localhost:9090

with all these setups, the server's process consumed 976.2MB of memory, but when compile it with --gc:orc and the default one everything seems to be okay with a memory usage of 478KB and 4.4MB respectively.

The code is as below:

import jester

settings:
  port = Port 9090

routes:
  get "/":
    resp "Hello World"

runForever()

Tested on:

$ uname -a
Linux iMachine 4.15.0-134-generic #138-Ubuntu SMP Fri Jan 15 10:52:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-01-23
Copyright (c) 2006-2021 by Andreas Rumpf
BLeAm commented 3 years ago

I've cross-posted to the Nim repo, https://github.com/nim-lang/Nim/issues/16862, and got the clarification, turns out this is a known and expected behavior, not a bug. So, this is closed now.