Skip to content

Commit 55ab4a9

Browse files
committed
feat(schema-compiler): Reduce memory usage after compilation is done
1 parent 90c5838 commit 55ab4a9

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeDictionary.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ export class CubeDictionary {
1313
resolveCube(cubeName) {
1414
return this.byId[cubeName];
1515
}
16+
17+
free() {
18+
this.byId = {};
19+
}
1620
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ export class CubeSymbols {
214214
this.evaluateViews = evaluateViews;
215215
}
216216

217+
public free() {
218+
this.symbols = {};
219+
this.builtCubes = {};
220+
this.cubeDefinitions = {};
221+
this.funcArgumentsValues = {};
222+
this.cubeList = [];
223+
this.resolveSymbolsCallContext = undefined;
224+
}
225+
217226
public compile(cubes: CubeDefinition[], errorReporter: ErrorReporter) {
218227
this.cubeDefinitions = Object.fromEntries(
219228
cubes.map((c): [string, CubeDefinition] => [c.name, c])

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ export class DataSchemaCompiler {
335335
if (!this.omitErrors) {
336336
this.throwIfAnyErrors();
337337
}
338+
// Free unneeded resources
339+
this.cubeDictionary.free();
340+
this.cubeSymbols.free();
338341
return res;
339342
});
340343
}

0 commit comments

Comments
 (0)