Closed jappeace closed 4 weeks ago
Actually looks fine if I increase the limit to 200, it just needs more then 83M after a while.
NB: I did have a memory leak but not due to amazonka. I got better at using the profiler while investigating this. It was caused by addKatipContext being used recursively.
It's good that you have runResourceT
inside the loop, because http requests can leak until you exit the ResourceT
: https://github.com/snoyberg/http-client/issues/537
It might be worth splitting the loop so you can reuse the manager for ~20 requests or so (to take a number from a hat). But that's independent of your addKatipContext
space leak.
Running the following code:
With
"-with-rtsopts=-N -K1K -M83M"
will fail after a couple cycles, for example:The heap shouldn't build up at all.
See full reproducer repo: https://github.com/jappeace/amazonka-reproduce/blob/master/src/Template.hs
My current work around is to write a custom recursive function and use
send
, which seems to leak less. I also noted that not using-N
drastically reduces the amount of heap memory used by the program (from 85 to around 18), and seems to mitigate this leak