Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Dominique Pellé
Raheel Gupta  wrote:

> Sir, is there any way to not allow malloc to hold memory ? I mean shouldnt
> free(), be freeing the memory ?

free() frees memory in the heap, making it available to other
malloc again. But it does not necessarily shrink the amount of
memory used by the process as was already explained by
multiple replies.

The OS does not necessarily shrink the memory of the process, when
calling free() because that may be reused when the process allocate
again.  Shrinking/growing has a cost. But does it really matter to
you that it does not shrink anyway? Pages that are not used will
be paged out if other processes need more memory and if the page
are really unused, then they will remain paged-out (no swapping) which
has probably no performance penalty. It will use more virtual memory
but it does not matter (unless of course you run out of virtual memory).
How much physical memory is actively being used is what matters.

Not also that just because you freed plenty of memory does
not mean the OS can always reclaim the pages from the process
anyway in case your heap was fragmented with tiny blocks still
allocated all scattered all over the heap.

Worth reading:

http://unix.stackexchange.com/questions/53447/does-free-unmap-the-memory-of-a-process

http://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_3.html

Quoting the above link:

=== BEGIN QUOTE ===
Occasionally, free can actually return memory to the operating system
and make the process smaller. Usually, all it can do is allow a later call
to malloc to reuse the space. In the meantime, the space remains in
your program as part of a free-list used internally by malloc.
=== END QUOTE ===

Regards
Dominique
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Nico Williams
On Tue, Oct 29, 2013 at 01:22:39AM +0530, Raheel Gupta wrote:
> Sir, is there any way to not allow malloc to hold memory ? I mean shouldnt
> free(), be freeing the memory ?

No.  The way malloc() typically works is that it allocates large chunks
of memory from the OS's kernel, then it allocates chunks of the desired
size to the callers of malloc().  Over time the heap (the large chunks
of memory that malloc() uses for making small allocations) gets
fragmented.  Once a heap is fragmented it's impossible to return some of
those large chunks of memory to the OS kernel, not without a garbage
collector that relocates memory, but C doesn't have a standard garbage
collector (much less one that rewrites memory!).

What SQLite3 could do is use mmap() to allocate its page cache, and then
it could munmap() pages when it's done with them.  But it doesn't do
this.  Or SQLite3 could dispense with the page cache and just mmap() the
whole file (or windows into it) and let the OS do all the caching.  But
SQLite3 cannot force the free() to return memory to the OS.

Nico
-- 
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Ryan Johnson

On 28/10/2013 3:57 PM, Richard Hipp wrote:

On Mon, Oct 28, 2013 at 3:52 PM, Raheel Gupta  wrote:


Sir, is there any way to not allow malloc to hold memory ? I mean shouldnt
free(), be freeing the memory ?


You'lll need to speak with the developers of your libc implementation about
that.
... but if you do that, be prepared to explain why both of the following 
apply to your program:
- it does not exit right after freeing that memory and it does not 
allocate more memory later
- some other process in your system is experiencing malloc() failures or 
excessive page faults because the memory has not been returned to the OS


A libc developer is unlikely to take the issue seriously unless both of 
those statements are true for your situation.


Ryan

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Richard Hipp
On Mon, Oct 28, 2013 at 3:52 PM, Raheel Gupta  wrote:

> Sir, is there any way to not allow malloc to hold memory ? I mean shouldnt
> free(), be freeing the memory ?
>

You'lll need to speak with the developers of your libc implementation about
that.
-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Raheel Gupta
Sir, is there any way to not allow malloc to hold memory ? I mean shouldnt
free(), be freeing the memory ?


On Tue, Oct 29, 2013 at 1:19 AM, Richard Hipp  wrote:

> On Mon, Oct 28, 2013 at 3:47 PM, Raheel Gupta  wrote:
>
> >
> > Then I ran "Pragma shrink_memory"
> >
> > Memory Used: 152584 (max 131658680) bytes
> > Number of Outstanding Allocations:   79 (max 2081)
> >
>
> So, after running "PRAGMA shrink_memory", SQLite has reduced its memory
> holdings to 152KB in 79 separate memory allocations.If your OS says the
> process is using more memory than that, then the extra memory must be used
> by the application or else be reusable freespace still held by your
> malloc() implementation.
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Richard Hipp
On Mon, Oct 28, 2013 at 3:47 PM, Raheel Gupta  wrote:

>
> Then I ran "Pragma shrink_memory"
>
> Memory Used: 152584 (max 131658680) bytes
> Number of Outstanding Allocations:   79 (max 2081)
>

So, after running "PRAGMA shrink_memory", SQLite has reduced its memory
holdings to 152KB in 79 separate memory allocations.If your OS says the
process is using more memory than that, then the extra memory must be used
by the application or else be reusable freespace still held by your
malloc() implementation.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Raheel Gupta
Hi,

After running my query :
Memory Used: 131655360 (max 131656000) bytes
Number of Outstanding Allocations:   2079 (max 2081)
Number of Pcache Overflow Bytes: 131567752 (max 131567752) bytes
Number of Scratch Overflow Bytes:0 (max 0) bytes
Largest Allocation:  65784 bytes
Largest Pcache Allocation:   65784 bytes
Largest Scratch Allocation:  0 bytes
Lookaside Slots Used:18 (max 36)
Successful lookaside attempts:   76
Lookaside failures due to size:  19
Lookaside failures due to OOM:   0
Pager Heap Usage:131536576 bytes
Page cache hits: 2
Page cache misses:   5298
Page cache writes:   0
Schema Heap Usage:   2536 bytes
Statement Heap/Lookaside Usage:  4016 bytes
Fullscan Steps:  0
Sort Operations: 0
Autoindex Inserts:   0

Then I ran "Pragma shrink_memory"

Memory Used: 152584 (max 131658680) bytes
Number of Outstanding Allocations:   79 (max 2081)
Number of Pcache Overflow Bytes: 65536 (max 131567752) bytes
Number of Scratch Overflow Bytes:0 (max 0) bytes
Largest Allocation:  65784 bytes
Largest Pcache Allocation:   65784 bytes
Largest Scratch Allocation:  0 bytes
Lookaside Slots Used:3 (max 36)
Successful lookaside attempts:   80
Lookaside failures due to size:  22
Lookaside failures due to OOM:   0
Pager Heap Usage:66344 bytes
Page cache hits: 0
Page cache misses:   0
Page cache writes:   0
Schema Heap Usage:   2536 bytes
Statement Heap/Lookaside Usage:  1408 bytes
Fullscan Steps:  0
Sort Operations: 0
Autoindex Inserts:   0



On Mon, Oct 28, 2013 at 6:51 PM, Richard Hipp  wrote:

> On Mon, Oct 28, 2013 at 9:16 AM, Raheel Gupta  wrote:
>
> > >> Whether or not free() returns that space to the operating system or
> > keeps
> > it around to satisfy future malloc() calls is a detail of the
> > implementation of free().
> >
> > Sir, anyway to be sure of that ?
> >
> > In the command-line shell, do ".stats on".  Then run your commands.
> Monitor the "Memory Used:" and "Number of Outstanding Allocations:"
> answers.  What do they tell you?
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Richard Hipp
On Mon, Oct 28, 2013 at 9:16 AM, Raheel Gupta  wrote:

> >> Whether or not free() returns that space to the operating system or
> keeps
> it around to satisfy future malloc() calls is a detail of the
> implementation of free().
>
> Sir, anyway to be sure of that ?
>
> In the command-line shell, do ".stats on".  Then run your commands.
Monitor the "Memory Used:" and "Number of Outstanding Allocations:"
answers.  What do they tell you?


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Raheel Gupta
>> Whether or not free() returns that space to the operating system or keeps
it around to satisfy future malloc() calls is a detail of the
implementation of free().

Sir, anyway to be sure of that ?



On Mon, Oct 28, 2013 at 5:45 PM, Richard Hipp  wrote:

> On Mon, Oct 28, 2013 at 8:13 AM, Raheel Gupta  wrote:
>
> > >> Then you have answered your question. The amount of memory still being
> > used is the size of the cache.
> >
> > Sir, that is the PEAK usage it goes upto.
> > After "PRAGMA shrink_memory" it goes down only to 65MB, which is 1000
> Pages
> > as per 64K page sizes.
> > Shouldnt it go down to the original usage of around 2-3 MB ?
> > No matter what you do the 65MB usage is always there.
> >
>
>
> SQLite is invoking the free() library routine on the excess memory.
> Whether or not free() returns that space to the operating system or keeps
> it around to satisfy future malloc() calls is a detail of the
> implementation of free().  SQLite has no control over that.
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Richard Hipp
On Mon, Oct 28, 2013 at 8:13 AM, Raheel Gupta  wrote:

> >> Then you have answered your question. The amount of memory still being
> used is the size of the cache.
>
> Sir, that is the PEAK usage it goes upto.
> After "PRAGMA shrink_memory" it goes down only to 65MB, which is 1000 Pages
> as per 64K page sizes.
> Shouldnt it go down to the original usage of around 2-3 MB ?
> No matter what you do the 65MB usage is always there.
>


SQLite is invoking the free() library routine on the excess memory.
Whether or not free() returns that space to the operating system or keeps
it around to satisfy future malloc() calls is a detail of the
implementation of free().  SQLite has no control over that.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Raheel Gupta
>> Then you have answered your question. The amount of memory still being
used is the size of the cache.

Sir, that is the PEAK usage it goes upto.
After "PRAGMA shrink_memory" it goes down only to 65MB, which is 1000 Pages
as per 64K page sizes.
Shouldnt it go down to the original usage of around 2-3 MB ?
No matter what you do the 65MB usage is always there.


On Mon, Oct 28, 2013 at 5:20 PM, Simon Slavin  wrote:

>
> On 28 Oct 2013, at 10:45am, Raheel Gupta  wrote:
>
> >>> PRAGMA cache_size
> >
> > I have set that 2000 in both cases.
>
> Then you have answered your question.  The amount of memory still being
> used is the size of the cache.
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Simon Slavin

On 28 Oct 2013, at 10:45am, Raheel Gupta  wrote:

>>> PRAGMA cache_size
> 
> I have set that 2000 in both cases.

Then you have answered your question.  The amount of memory still being used is 
the size of the cache.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Raheel Gupta
>>  If you multiply that by your page size do you get the amount of memory
you see being used

During peak usage the memory reaches 126 MB which is similar to 2000 x 64K.
After "PRAGMA shrink_memory" it goes down only to 65MB, which is 1000 Pages
as per 64K page sizes.



On Mon, Oct 28, 2013 at 4:15 PM, Raheel Gupta  wrote:

> >> PRAGMA cache_size
>
> I have set that 2000 in both cases.
>
>
> On Sun, Oct 27, 2013 at 7:49 PM, Simon Slavin wrote:
>
>>
>> On 27 Oct 2013, at 5:10am, Raheel Gupta  wrote:
>>
>> > But why would this happen with 64K pages ? In 1024 Sqlite is able to
>> > release all the memory.
>>
>> I doubt it's releasing all the memory.  It's probably holding on to a few
>> pages.  But the pages are so small that the memory usage doesn't register.
>>
>> What's your setting for
>>
>> PRAGMA cache_size
>>
>> ?  If you multiply that by your page size do you get the amount of memory
>> you see being used ?
>>
>> Simon.
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-28 Thread Raheel Gupta
>> PRAGMA cache_size

I have set that 2000 in both cases.


On Sun, Oct 27, 2013 at 7:49 PM, Simon Slavin  wrote:

>
> On 27 Oct 2013, at 5:10am, Raheel Gupta  wrote:
>
> > But why would this happen with 64K pages ? In 1024 Sqlite is able to
> > release all the memory.
>
> I doubt it's releasing all the memory.  It's probably holding on to a few
> pages.  But the pages are so small that the memory usage doesn't register.
>
> What's your setting for
>
> PRAGMA cache_size
>
> ?  If you multiply that by your page size do you get the amount of memory
> you see being used ?
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-27 Thread Simon Slavin

On 27 Oct 2013, at 5:10am, Raheel Gupta  wrote:

> But why would this happen with 64K pages ? In 1024 Sqlite is able to
> release all the memory.

I doubt it's releasing all the memory.  It's probably holding on to a few 
pages.  But the pages are so small that the memory usage doesn't register.

What's your setting for

PRAGMA cache_size

?  If you multiply that by your page size do you get the amount of memory you 
see being used ?

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Dominique Pellé
Raheel Gupta wrote:

> Hi,
>
> Yes, I tried Valgrind and it shows no leaks.
> But why would this happen with 64K pages ? In 1024 Sqlite is able to
> release all the memory.
>
>>> It might also be that your memory allocator is holding onto freed memory
> rather than releasing it back to the OS.
>
> How should I free it ?


Most certainly the memory has been freed.  But that does not
mean that the OS will reduce memory usage of the process.

Valgrind memcheck already showed that there is no leak
as you said.  If you still think that memory is allocated, you
can use a heap profiler such as "valgrind --tool=massif" to
find where memory is allocated, and how much of it is
allocated.  See:

http://valgrind.org/docs/manual/ms-manual.html

There are other heap profilers, such as this one:
http://google-perftools.googlecode.com/svn/trunk/doc/heapprofile.html

Regards
Dominique
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Raheel Gupta
>> Whether and how you can do so will depend on what operating system you
are
using.

I am using a CentOS 6.4
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Christopher Vance
Whether and how you can do so will depend on what operating system you are
using.


On 27 October 2013 16:10, Raheel Gupta  wrote:

> Hi,
>
> Yes, I tried Valgrind and it shows no leaks.
> But why would this happen with 64K pages ? In 1024 Sqlite is able to
> release all the memory.
>
> >> It might also be that your memory allocator is holding onto freed memory
> rather than releasing it back to the OS.
>
> How should I free it ?
>
>
>
> On Sun, Oct 27, 2013 at 9:46 AM, Richard Hipp  wrote:
>
> > On Sun, Oct 27, 2013 at 12:02 AM, Raheel Gupta 
> > wrote:
> >
> > > Hi,
> > >
> > > Sir, if you see my first email, I have already tried that. When the 15
> > > Million records are being outputted, the ram usage shoots to a MAX of
> > > 126MB. After the "PRAGMA shrink_memory" it goes down to 65Mb but doesnt
> > go
> > > below that.
> > >
> > >
> > It might also be that your memory allocator is holding onto freed memory
> > rather than releasing it back to the OS.  Have you tried running with
> > valgrind to see it shows any leaks?
> >
> > --
> > D. Richard Hipp
> > d...@sqlite.org
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Christopher Vance
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Raheel Gupta
Hi,

Yes, I tried Valgrind and it shows no leaks.
But why would this happen with 64K pages ? In 1024 Sqlite is able to
release all the memory.

>> It might also be that your memory allocator is holding onto freed memory
rather than releasing it back to the OS.

How should I free it ?



On Sun, Oct 27, 2013 at 9:46 AM, Richard Hipp  wrote:

> On Sun, Oct 27, 2013 at 12:02 AM, Raheel Gupta 
> wrote:
>
> > Hi,
> >
> > Sir, if you see my first email, I have already tried that. When the 15
> > Million records are being outputted, the ram usage shoots to a MAX of
> > 126MB. After the "PRAGMA shrink_memory" it goes down to 65Mb but doesnt
> go
> > below that.
> >
> >
> It might also be that your memory allocator is holding onto freed memory
> rather than releasing it back to the OS.  Have you tried running with
> valgrind to see it shows any leaks?
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Richard Hipp
On Sun, Oct 27, 2013 at 12:02 AM, Raheel Gupta  wrote:

> Hi,
>
> Sir, if you see my first email, I have already tried that. When the 15
> Million records are being outputted, the ram usage shoots to a MAX of
> 126MB. After the "PRAGMA shrink_memory" it goes down to 65Mb but doesnt go
> below that.
>
>
It might also be that your memory allocator is holding onto freed memory
rather than releasing it back to the OS.  Have you tried running with
valgrind to see it shows any leaks?

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Raheel Gupta
Hi,

Sir, if you see my first email, I have already tried that. When the 15
Million records are being outputted, the ram usage shoots to a MAX of
126MB. After the "PRAGMA shrink_memory" it goes down to 65Mb but doesnt go
below that.


On Sun, Oct 27, 2013 at 4:55 AM, Richard Hipp  wrote:

> On Sat, Oct 26, 2013 at 3:03 PM, Raheel Gupta  wrote:
>
> >
> > This leads me to conclude that there is some kind of Memory Leakage when
> > the page size is 64K.
> >
> > How can I bring down the memory usage atleast when I shrink_memory after
> > the query executes.
> >
>
>
> Doubtful.  Probably the excess memory is just be used for the page cache.
>
> Did you try running "PRAGMA shrink_memory"?
> http://www.sqlite.org/pragma.html#pragma_shrink_memory - that will force
> the cache to flush.
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Raheel Gupta
>> Try letting SQLite use its default for your platform.

The default when the database is created is 1024.
It works well in that page size as I have mentioned in my first email.
The issue is with 65536.
Why should there be a memory leak when the page size is 65536 ?

I have to use 65536 to enable the storing of huge amount of data.
With a page size of 65536 I can store upto 140 TB (theorotically - but I
need 8 TB for sure). When the page size is 1024 I can store a max of 2 TB.

I have found 65536 3-5% slower than the usual 1024 page size.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Richard Hipp
On Sat, Oct 26, 2013 at 3:03 PM, Raheel Gupta  wrote:

>
> This leads me to conclude that there is some kind of Memory Leakage when
> the page size is 64K.
>
> How can I bring down the memory usage atleast when I shrink_memory after
> the query executes.
>


Doubtful.  Probably the excess memory is just be used for the page cache.

Did you try running "PRAGMA shrink_memory"?
http://www.sqlite.org/pragma.html#pragma_shrink_memory - that will force
the cache to flush.


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Simon Slavin

On 26 Oct 2013, at 8:03pm, Raheel Gupta  wrote:

> How can I bring down the memory usage atleast when I shrink_memory after
> the query executes.

You stop using such big pages.

Try letting SQLite use its default for your platform.  Do an export and 
reimport without using any PRAGMAs at all.  Then test your SELECT (or all the 
SELECTs which give you problems).  Are they much slower than the version where 
you set pagesizes yourself ?

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQlite Memory Leakage with 65536 Page Size

2013-10-26 Thread Raheel Gupta
Hi,

I am using a Page Size of 65536 and I have found the performance good
enough for me until now.
I have the database having the following table:

CREATE TABLE map (
n BIGINT NOT NULL DEFAULT 0,
s INT(5) NOT NULL DEFAULT 0,
d INT(5) NOT NULL DEFAULT 0,
c INT(1) NOT NULL DEFAULT 0,
b UNSIGNED BIGINT NOT NULL DEFAULT 0
);
CREATE INDEX map_index ON map (d, n, s, c, b);

This table has around 600 Million records.

I do the following :
root> sqlite3 my.db
sqlite> SELECT * FROM map where d = 15;

There are around 15 Million records for 'd' column with value 15.

As the rows are outputted the memory usage of sqlite shoots to 126 MB
(which I assume is 2000 pages x 64KB which is ok).

After the query is finished I run the following :
sqlite> pragma shrink_memory;

The memory drops to 65M.

I then dumped the database and re-imported it into a newer database with
page size as 1024. When running the select query the memory usage doesnt
cross 5-6 MB and shrink_memory reduces it back to near 2 MB.

I am checking the memory usage with the following :
root> top -d 1 -p `pidof sqlite3`

This leads me to conclude that there is some kind of Memory Leakage when
the page size is 64K.

How can I bring down the memory usage atleast when I shrink_memory after
the query executes.

I have tried this on SQLITE 3.8.1 and SQLITE 3.7.17

Regards
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users