leaf
leaf copied to clipboard
Memory Leak on View Render with Encodable Struct/Enum
Describe the bug
When decoding both Encodable structs and enums as a context object for a view render, I have found that there appears to be a small memory leak. The memory leak mostly vanishes when the route returns a View containing a ByteBuffer from a string, describing the struct, in that way ensuring everything else but the final render is compiled in. It does seem like there's still a tiny memory leak though, so it may be that the leak's still there, just significantly minimized.
To Reproduce
- Create a template project
- (to speed up the leak) Create a struct, and apply the struct to the template as a context object
- Stress test it with curl in an infinite while loop
Expected behavior
Memory stays mostly consistent within a normal range for the workload
Environment
This is all being run on Linux. Here's a copy of framework versions
- Vapor Framework version: 4.65.1
- Vapor Toolbox version: ...
- OS version: Ubuntu 22.04.1 LTS
Additional context
This is completely consistent. I'd love some insight into what's going on here. This project is for a business, so I'll have to write some nasty workarounds if I can't figure this out. Best avoided, obviously.
found a reference cycle. I'll send in a PR in a bit.
PR: https://github.com/vapor/leaf/pull/216