use of io.questdb.cairo.sql.BindVariableService in project questdb by bluestreak01.
the class MemoryLeakTest method testQuestDbForLeaks.
@Test
public void testQuestDbForLeaks() throws Exception {
assertMemoryLeak(() -> {
int N = 1_000_000;
populateUsersTable(engine, N);
try (SqlCompiler compiler = new SqlCompiler(engine)) {
final BindVariableService bindVariableService = new BindVariableServiceImpl(configuration);
bindVariableService.setLong("low", 0L);
bindVariableService.setLong("high", 0L);
try (final SqlExecutionContextImpl executionContext = new SqlExecutionContextImpl(engine, 1).with(AllowAllCairoSecurityContext.INSTANCE, bindVariableService, null)) {
StringSink sink = new StringSink();
sink.clear();
sink.put("users");
sink.put(" latest by id where sequence > :low and sequence < :high");
try (RecordCursorFactory rcf = compiler.compile(sink, executionContext).getRecordCursorFactory()) {
bindVariableService.setLong("low", 0);
bindVariableService.setLong("high", N + 1);
Misc.free(rcf.getCursor(executionContext));
}
}
} finally {
Assert.assertEquals(Unsafe.getMemUsed(), getUsed());
engine.clear();
Assert.assertEquals(Unsafe.getMemUsed(), getUsed());
}
});
}
Aggregations