Skip to content

Memory leak #71

@wolfgang371

Description

@wolfgang371
require "sqlite3"

DBFILE = "test.db"

db = DB.open("sqlite3://./#{DBFILE}")
while true
    begin
        db.scalar("select padding from foo where id=#{Random.rand(100000000)}") # size matters!
    rescue DB::NoResultsError
    end
end

grows beyond 32GB of RAM on my machine in a couple of minutes.

For the setup you need:
https://www.sqlite.org/src/file/ext/misc/series.c
https://www.sqlite.org/loadext.html: gcc -g -fPIC -shared series.c -o series.so

save the lines below in setup.sql, then
cat setup.sql | sqlite3 test.db

.load ./series
.header on
.timer on
drop table if exists foo;
create table foo (id int, padding text);
insert into foo (id, padding) select value, random() from generate_series(1, 100000000) order by random();
create index foo_id_ix on foo (id);

I use crystal 1.1.1 on Ubuntu 18.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions