4 Replies Latest reply: Sep 23, 2013 2:28 PM by userBDBDMS-Oracle Branched to a new discussion. RSS

    A big bug in BDB on Win7 x64

      Please Read the Code,the code is right on x86, but system will lost memory on x64

      when I run it on x64, the system will using a unknow memory as large as DBFile, but it can not see in thread, the thread is as normal large as you set_cachesize

      unknow memory = System Used Memory - System Commit Memory

      If close the program the unknow memory will free to system.

      My value is png image, read by ACE_Message_block.

      if my DBFile is big then my system memory, the program will wait new memory.

      What wrong about BDB???

      ACE_UINT64 Key( int Level , int Row , int Col )


      ACE_UINT64 Result = Level & 0x0FF ;//屏蔽高位

      Result <<= 28 ;//左移位

      Result |= Row & 0x0FFFFFFF ;//屏蔽高位并与Result做或运算

      Result <<= 28 ;//左移位

      Result |= Col & 0x0FFFFFFF ;//屏蔽高位并与Result做或运算

      return Result;


      void readDB()


      DbEnv* Env = new DbEnv( 0 );


      int env_flags = DB_CREATE | // If the environment does not exist, create it

      DB_PRIVATE |

      //DB_INIT_LOCK | // Initialize locking

      // DB_INIT_LOG | // Initialize logging

      DB_INIT_MPOOL ;//| // Initialize the cache

      //DB_THREAD ; // Initialize transactions

      //Env->set_mp_pagesize( 1024 * 8 );

      if ( Env->set_cachesize( 0, 1*1024*1024, 1) == 0 && Env->open( NULL, env_flags, 0 ) == 0 )


      //return 0;


      Db* db = new Db( 0, 0 );//no dbenv

      if (

      0 == db->open( NULL, "D:\\RASTER_JPEG_60_64_1.db" , NULL ,DB_BTREE, DB_RDONLY ,NULL)



      //ISF_DEBUG( "Open DB: %s Succeed" , "D:\\RASTER_JPEG_60_4_1_x64.db" );

      //return 0;


      for ( int m=100;m<900;m++)


      for (int n=100;n<900;n++)


      ACE_UINT64 key=Key(11,m,n);

      Dbt dbKey(&key,sizeof(key));

      Dbt dbData;




      int a;


        • 1. Re: A big bug in BDB on Win7 x64

          Could you please let us know what version you are using now? From your code, I assume you use C++ API.

          A few comments to your code:
          DB_PRIVATE |
          When an environment is opened with DB_PRIVATE, region memory would be allocated from the heap.
          //DB_THREAD ; // Initialize transactions
          This is for multi-threaded, not for transaction.
          Db* db = new Db( 0, 0 );//no dbenv
          This db is not opened within the dbenv, so all the settings for the opened dbenv won't work for the db.

          I would suggest you to refer to our C++ examples. In the latest source code, it is under examples/cxx/*.

          Also, please use English in your post so that everyone could understand and help you:-)

          Emily Fu
          Oracle Berkeley DB
          • 2. Re: A big bug in BDB on Win7 x64
            Whatever version I used in x64, include the oldest or lastest version or the version before the lastest, Whatever open the DB in DBEnv or not , It will always lost memory in system. And like virtual pc in vmware , can see memory used in system but not in any thread. But it will normal in x86.
            I will send some pic to your e-mail, please check it.
            • 3. Re: A big bug in BDB on Win7 x64
              Your can download my testDB to test it on win7 x64

              The Db size is 781mb, if you run my code on it,you will found system memory lost 781mb
              And if exec the db.close(), the memory will back and thread memory will always at 1-2mb.
              • 4. Re: A big bug in BDB on Win7 x64

                this discussion has been continue on this thread: https://forums.oracle.com/message/11194083#11194083


                Thei appears to be an issue with the Windows System Cache.  See thread: https://forums.oracle.com/thread/2571599