Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Berkeley DB is taking up too much memory

593850Aug 20 2007 — edited Aug 23 2007
Hi,

I have 2 issues:
1. The application it taking up lot more memory that I think it should
2. The page-size setting isn't working on one box but works on the other

Background:
I am running an application that caches binary data with each data-record roughly 800kb in size. My test application is caching about 2000 records. So the total data-size is round 1.6gb. (The real application will be dealing with total data-size of around 25gb)

Here's my runtime environment:
I am using Berkeley DB version 4.5.20 on Linux Red Hat AS3
I am using B-Tree access.
I have specified a cache-size of 400mb
I am specifying the following flags during the init of my dbEnv: DB_CREATE, DB_THREAD, DB_INIT_LOCK, DB_INIT_LOG, DB_INIT_MPOOL, DB_INIT_TXN.

Since I have specified the cache-size to be 400mb, I was expecting the application to take around 400mb in additional memory and the rest of the data to be buffered on the file-system. But interestingly, Berkeley DB attaches the whole “db” file (which is around 1.4gb) to memory.

Here’s the output from db_stat for my database:
2 Minimum keys per-page
4096 Underlying database page size
1007 Overflow key/data size
3 Number of levels in the tree
1998 Number of unique keys in the tree
1998 Number of data items in the tree
4 Number of tree internal pages
10266 Number of bytes free in tree internal pages (37% ff)
72 Number of tree leaf pages
117216 Number of bytes free in tree leaf pages (60% ff)
0 Number of tree duplicate pages
0 Number of bytes free in tree duplicate pages (0% ff)
356076 Number of tree overflow pages
4929336 Number of bytes free in tree overflow pages (99% ff)
0 Number of empty pages
0 Number of pages on the free list

Here are the data/log files on the file-system:
12K __db.001
4.1M __db.002
501M __db.003
28K __db.004
236K __db.005
12K __db.006
28K log.0000000001
1.4G RateFilesCache.db

When I run the application the free memory drops from around 4.6gb to around 2.7gb. Later when I delete the __db.003 file and the RateFilesCache.db, all this memory is reclaimed. Why is Berkeley DB attaching my entire data to memory?

For the second part of my question, I am specifying a page-size of 64k by doing db.set_pagesize(). This works on one Linux box but not on the other. The other box is defaulting the page-size to 4k. Why would this happen?

Also, I would appreciate if you can suggest additional tuning that would be appropriate for the BLOB size of close to 1mb that I am dealing with.

Thanks in advance,

Shashi
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 20 2007
Added on Aug 20 2007
5 comments
2,236 views