Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.36k stars 280 forks source link

Excessive memory usage of Tera #905

Closed schungx closed 3 months ago

schungx commented 3 months ago

I am using Loco (which embeds Tera) to render heavily-templated HTMX views.

My program consistently uses up to 5-6GB of RAM whenever complex Tera pages are rendered. Then this RAM stays (cached in Tera?) until a period of idleness (typically a few minutes), then Tera would dump them all off and the program RAM usage falls significantly (to below 1GB).

I am wondering: Is Tera caching the output of previous template runs or something? Why is it using so much RAM, and why does it keeps this memory alive for minutes?

Keats commented 3 months ago

Tera is not caching anything except for the template string and AST.

schungx commented 3 months ago

Do you know what can be using up gigabytes of RAM? I'm not rendering very large templates, at for-loops only at most 4-5 rounds. These are tests...

And it is strange that, after maybe 1 minute of inactivity, it suddenly releases all this memory all at once...

But if I don't touch Tera templates (e.g. use only the JSON API), nothing like this happens.

schungx commented 3 months ago

This may not be Tera related. Sorry for the false alarm. I'll close now.