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!

Lost many cache on linux ,the build 4.5.20

586320Jul 4 2007 — edited Jul 18 2007
when I run the under codes in linux, my computer lost many cache,until
only 10M memory free.
why ?
Is my code error,or other problem?

the code is:

#include <stdio.h>
#include <stdlib.h>
#include "db_cxx.h"
#include <memory>
using namespace std;
int main(int argc,char **argv)
{
unsigned long num_record=1024;
if(2==argc)
{
num_record=atoi(argv[1]);
}
u_int32_t db_flags = DB_CREATE | DB_THREAD|DB_NOMMAP;
//auto_ptr < Db > dbp(new Db(NULL, 0));
auto_ptr < Db > dbp(new Db(NULL, DB_CXX_NO_EXCEPTIONS));
#if 0
dbp->set_error_stream(&cerr);
dbp->set_errpfx("bdb_cache_test");
dbp->set_pagesize(1024); // 1K page sizes.
dbp->set_flags(DB_RECNUM); // Record numbers.
#endif
//dbp->set_cachesize (0, 0, 0);
//dbp->open(NULL, "database.bdb", NULL, DB_RECNO, db_flags, 0);
dbp->open(NULL, "database.bdb", NULL, DB_BTREE, db_flags, 0);
unsigned long auto_primekey=0;
char *str="asdfg,hjkl,zxcvbnm,qwertyuiop";
int str_len=strlen(str);
while(1)
{
Dbt key(&auto_primekey,sizeof(unsigned long)),data(str,str_len);
dbp->put(0,&key,&data,0);
//dbp->sync(0); //if have this line,will lost cache more quikly
auto_primekey++;
if(auto_primekey>num_record)
{
printf("num_record=%ld\n",num_record);
break;
}
}
dbp->close(0);
printf("you are in main!\n");
return 0;
};
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 15 2007
Added on Jul 4 2007
16 comments
2,619 views