Yes, I can see that SQLite is doing just small allocations using memory
methods.

I also tried to limit the size of database using following two methods

     rc = sqlite3_config(SQLITE_CONFIG_HEAP, buffer, 5000000, 64);
    if(rc != SQLITE_OK)
    {
        printf("Failed to set custom heap memory\n");
    }

    rc = sqlite3_soft_heap_limit64(1000000);
    printf("Prev: %d\n", rc);

When I use both of them as in this example, I get usage of DB of around
22MB, what is not so bad.
Using of small heap (array in my case) should be fine for my application,
as it is going to use just small databases (1 - 3MB).

What do you think about this technique ? I think, it could be very
dangerous when size of database grows, but that should not happen.
Thank you and Regards,
Martin

2018-07-13 20:58 GMT+02:00 Richard Hipp <d...@sqlite.org>:

> On 7/13/18, Martin Vystrčil <vystrcil.mar...@gmail.com> wrote:
> >
> > But still, I would like to solve this somehow, could you please suggest
> me
> > some point, where to start ? Are there any possible compilation options,
> to
> > limit this allocation ?
>
> It is not SQLite that is doing this allocation.  I suspect it is
> something happening inside of the malloc() in your libc.
>
> You can see the SQLite is never doing a huge allocation by calling
> sqlite3_memory_highwater(0) in place of sqlite3_memory_used().
>
> You are probably better off letting malloc() do whatever allocations
> it wants.  However, if you really want to work around this, there are
> ways of getting SQLite to use a memory allocator other than the
> default system malloc().  See https://www.sqlite.org/malloc.html for
> further information.  These are sharp techniques, so be careful.  But
> if you do it right, you can limit the memory usage of SQLite to
> whatever you want.
> --
> D. Richard Hipp
> d...@sqlite.org
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to