leaf icon indicating copy to clipboard operation
leaf copied to clipboard

Memory Leak on View Render with Encodable Struct/Enum

Open dschwartz783 opened this issue 1 year ago • 2 comments

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

  1. Create a template project
  2. (to speed up the leak) Create a struct, and apply the struct to the template as a context object
  3. 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.

dschwartz783 avatar Sep 09 '22 04:09 dschwartz783

found a reference cycle. I'll send in a PR in a bit.

dschwartz783 avatar Sep 10 '22 01:09 dschwartz783

PR: https://github.com/vapor/leaf/pull/216

dschwartz783 avatar Sep 10 '22 23:09 dschwartz783