Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directly outputting for large templates #53

Open
j-w-jones opened this issue Jun 7, 2022 · 3 comments
Open

Directly outputting for large templates #53

j-w-jones opened this issue Jun 7, 2022 · 3 comments

Comments

@j-w-jones
Copy link

Hi,

I have a few templates whose output is very long and I think the render() method captures all the output in a string before finally outputting it, which consumes a lot of memory.

Is there any way to get the template engine to print the output as it is generated?

Thanks,

Jason

@j-w-jones j-w-jones changed the title Directly outputting for large lua scripts Directly outputting for large templates Jun 7, 2022
@tonmanna
Copy link

image
I'm not sure whether I understand your question or not.
If the template is huge I think it no difference in memory consumption.

@j-w-jones
Copy link
Author

Sorry - having re-read my original post, I can see it could be confusing..

If I have a simple template that outputs 100Mb+ of text using a number of loops etc, the current implementation will store that entire output in a string in memory until the end of execution. The string would then be displayed on stdout. This means a simple template could end up using 100Mb+ of RAM.

Would there be a way of enabling the output from the template to be displayed immediately, rather than buffered in this way?

@bungle
Copy link
Owner

bungle commented Nov 3, 2022

Perhaps we should add somekind of streaming support and move to use LuaJIT string buffer (some things might be hard with that though, e.g. if using master pages etc. which we need to check if they are rendered lazily or not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants