fiber: ๐ Memory Leak from Compress middleware
Fiber version
v2.3.2
Issue description
My fiber server got killed several times due to OOM. Log shows the serverโs memory climbed over time and eventually took 3G ~ 4G before Linux kernel kills it.
Just remove the line app.Use(compress.New())
made the memory stable at around 100M.
pprof shows brotli was holding the memory.
Code snippet
package main
import "github.com/gofiber/fiber/v2"
func main() {
app := fiber.New()
// Steps to reproduce
app.Use(compress.New())
log.Fatal(app.Listen(":3000"))
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (8 by maintainers)
I found this issue valyala/fasthttp#782 and maybe you can try this solution .
@kiyonlin no, thereโs no large file. And Iโm able to reproduce it now with wrk.
server.go
Put a 1Mb
dummy.json
in the root, I use this. Start the server and runwrk -H "Accept-Encoding: gzip, br" -c 200 http://localhost:4000/dummy.json
Then you will see the memory go up to 4G:
When only use Gzip, the memory is around 250M.