Replies: 3 comments 11 replies
-
Hello @wdolek I do see couple possible things that can be done:
|
Beta Was this translation helpful? Give feedback.
-
What kind of memory footprint are you seeking to achieve? How much reduction would make this no longer a problem in your use case? |
Beta Was this translation helpful? Give feedback.
-
@zjklee yesterday we deployed our app with version 2.1.2 and enabled shared env - we got from ~900MiB to ~600MiB used. This will allow us to do further improvements as suggested in this discussion. Thank you 🙇 ! |
Beta Was this translation helpful? Give feedback.
-
We are using Handlebars for rendering localized templates. Having naive implementation of compiling each localized template separately we are getting to ~300MiB of compiled templates in memory.
Template compiled
N
times, each time with different "static" text:We have decided to fix this by compiling template once and just vary localized text in it. Unfortunately even that localized text may contain Handlebars syntax, so we thought we can:
... but this doesn't scale, because no matter how small compiled template is, it has over 30KiB.
We tried adding those dictionary entries as partial templates using
Handlebars.RegisterTemplate
- but there was no difference. When checked implementation it was obvious why - using partial template is the same as compiling it, but just registering it inside Handlebars Environment.To the main point, we can see that every time we compile template, there's
HandlebarsConfigurationAdapter configuration
associated to it. This object takes ~25KiB and for every compiled template it is new instance (pointing to different place in memory) of seemingly same configuration object. Now, having several thousand of small templates we need to compile we are again getting to tens or hundreds of MiBs allocated.Is there any way how to achieve:
HandlebarsConfigurationAdapter
in every compiled template?Beta Was this translation helpful? Give feedback.
All reactions