This discussion is archived
1 Reply Latest reply: Sep 18, 2013 12:36 AM by 3c325edf-a6cb-4015-beeb-de7a8b3d3be8 RSS

The DbEnv memery missing in win7 x64(may be a berkeley'Env bug in x64)

889525 Newbie
Currently Being Moderated
I am a newer programer in Berkeley,this is my first use it.
I create a BDB for png image, about 40gb, the key is used ACE_UINT64, the value is ACE_Message_Block.

I used LoadRunner create 100 user to get the image by my program.
It is correctly in win7 32bit, but it is lost memory in 64bit.

I open the Env with DB_Private | DB_init_pool | DB_thread, and set the cachesize to 1gb, also the DBt of value is set_flags(DB_DBT_MALLOC), also use free(DBt.getdata()).

My server thread's commit memory in taskmgr.exe is keep at 1gb, but the memory in used of system increase never stop, at last all of memey has been used, and my server thread stop at berkeleydb.

I find my used memory is 8gb, my system+loadruner+vs2008 at most 1.5gb, and my server thread keep in 1gb, what the other memory who used?

So I shut down the server thread, all memory came back.

So I change Berkeley DB Storage to Read my image.png direct in file system, the memory is correctly.

So must some wrong in my code to used berkeleydb, must in DBt’ alloc,so how can i free the memory in x64?

So I need helper, what’s the wrong with my DBEnv?How can I free the DBt in 64 bit?


int IMG_Storage_Environment::Initialize( ISF_Profile_Visitor & Profile )
{     
     Env = new DbEnv( 0 );
     int env_flags = DB_CREATE | // If the environment does not exist, create it
          DB_PRIVATE |
          DB_INIT_MPOOL | // Initialize the cache
          DB_THREAD ; // Free-thread the env handle
     if ( Env->set_cachesize( 1, 0, 1) == 0 &&     Env->open( NULL, env_flags, 0 ) == 0 )
     {
          return ERR_SUCCESS;
     }
}
int IMG_Storage_BerkeleyDB::Initialize( ACE_StrItrT Layer , ACE_StrItrT Path )
{     
     this->db = new Db( IMG_Storage_Environment::Instance()->getDbEnv(), 0 );
     if (
          0 == db->open( NULL, STR_T2A( Path ) , NULL ,DB_UNKNOWN, DB_RDONLY ,NULL)
          )
     {
          ISF_DEBUG( "Open DB: %s Succeed" , Path );
          return ERR_SUCCESS;
     }     
}
int IMG_Storage_BerkeleyDB::GetTile( int x , int y , int z , ACE_Message_Block & Data )
{
     ACE_UINT64 uKey=this->Key( x, y, z);
     Dbt dbKey(&uKey, sizeof(uKey));
     Dbt dbData;
     dbData.set_flags( DB_DBT_MALLOC );
     int err = db->get(NULL, & dbKey, & dbData, 0);
     if ( 0 == err )
     {
          Data.size( dbData.get_size( ) );
          Data.rd_ptr( Data.base( ) );
          Data.wr_ptr( dbData.get_size( ) );

          ACE_OS::memcpy( Data.rd_ptr( ) , dbData.get_data( ) , dbData.get_size( ) );
     }
     else
     {
          ISF_DEBUG( "Image Not exist, Using Empty Image" , err );
     }
     free(dbData.get_data());
     return ERR_SUCCESS;
}

Edited by: 886522 on 2011-9-21 上午1:31

Edited by: 886522 on 2011-9-21 上午1:39

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points