pierr wrote:
> 
> 
> D. Richard Hipp wrote:
>> 
>> 
>> On Jun 15, 2009, at 9:04 AM, pierr wrote:
>> 
>>>
>>> Hi all,
>>>       I am using an memory type sqlite database in our embedded
>>> application. After the applicate run a while ,the system will run  
>>> ourt of
>>> out of memory. So, is there a way to know how many memory is used by  
>>> sqlite?
>>> That would include the memory for page cache , any other other  
>>> internal
>>> memory used the sqlite ,as well as the memory for database itself.  
>>> Thanks
>>> for your help.
>> 
>> http://www.sqlite.org/c3ref/memory_highwater.html
>> http://www.sqlite.org/malloc.html
>> 
>> 
> 
> By using the memory_highwater api above , I found that most of the memory
> is used for page cache. By limiting the cache size , I can have a good
> control of how many heap memory will be used.
> 
> INSERT Record Numbers    PAGE SiZE   CACHE SIZE             HIGH WATER
> MARK
> (110bytes per record)
> 
> 1000                                1024           20                        
> 98,256
> 1000                                1024           2000                    
> 271,040
> 8000                                1024           2000                    
> 1,562,144
> 8000                                1024           20                        
> 99,200
> 
> And as Simon suggest ,when I close the connection, the memory used by
> sqlite will be Zero.
> 
> I am more clear about how sqlite use memory now , however ,as I am using
> memory database ,I also cares about the database size. That is what is
> proportion of database size to the raw data size.
> 
> I insert a record of 112 bytes 10,1000,and 10000 times repectively and
> here list the output database size. For The last case ,it has a propotion
> about 1.45. What cost the extra 0.45 here beside the btree? 
> 
>  10240      2009-06-17 14:38 /etc/eit.flash.sqlite.10
>  171008     2009-06-17 14:32 /etc/eit.flash.sqlite.1000
>  1634304   2009-06-17 14:42 /etc/eit.flash.sqlite.10000
> 
> (I am using the Flash database instead of the memory data here as I think
> the result should be the same.)
> 
> 


I was wrong here.

In my application (Not the test enviroment mentiond above), after the sqlite
eating up more than 8M bytes in the memory , I dumpded the database to the
Flash but it is only 360K which is very reasonable for my application. The
database was configured as cache_szie = 20 ,page_size=1024 ,so the page
cache would not take too much memory ,it should be less than 100K according
to above measurement. 

So, for the non-memory based data base ,the total storage needed is :
generated database size + memory used by sqlite3 internal.

But for the memory database, the total storage needed will be much bigger
than that. What will eat the extra buck of memory here?  I can think of the
journey file ,but it should be K level memory..

Thanks for help me out.
-- 
View this message in context: 
http://www.nabble.com/How-to-how-many-memory-is-used-by-sqlite-tp24034261p24073060.html
Sent from the SQLite mailing list archive at Nabble.com.

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

Reply via email to