Skip to content

Commit ec7ca2f

Browse files
authored
fix(schema-compiler): Free jinja instance after compilation (#10169)
Jinja instance stores all templates, because it resolves dependencies inside minijinja. If we have at least one jinja file, then compiler load all templates to jinja instance. Let's free it after compilation to reduce memory usage.
1 parent c12e5d6 commit ec7ca2f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,14 @@ export class DataSchemaCompiler {
532532
if (!this.omitErrors) {
533533
this.throwIfAnyErrors();
534534
}
535+
535536
// Free unneeded resources
536537
this.compileV8ContextCache = null;
537538
this.cubeDictionary.free();
538539
this.cubeOnlySymbols.free();
539540
this.cubeAndViewSymbols.free();
541+
this.yamlCompiler.free();
542+
540543
return res;
541544
});
542545
}

packages/cubejs-schema-compiler/src/compiler/YamlCompiler.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export class YamlCompiler {
3838
) {
3939
}
4040

41+
public free() {
42+
this.jinjaEngine = null;
43+
}
44+
4145
public getJinjaEngine(): JinjaEngine {
4246
if (this.jinjaEngine) {
4347
return this.jinjaEngine;

0 commit comments

Comments
 (0)