dbTalk Databases Forums  

Memory leak problem in BerklyDB

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss Memory leak problem in BerklyDB in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
pai
 
Posts: n/a

Default Memory leak problem in BerklyDB - 11-03-2006 , 07:30 AM






Hi BerklyUsers,

Bellow interface will be called for creating the DB handler,
int db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags);

Here memory will be allocted for the variable *dbp. Now while closing
the DB the corresponding handler also should be destroyed, otherwise it
will lead to a memory leak.

Now my query is that is there any interface to destroy the handler
created by funtion db_create? if there is no interface then where
BerklyDB will release this memory?

and is there any way to check the memory leaks in Berbly?

with regards,
Pai


Reply With Quote
  #2  
Old   
Patrick Schaaf
 
Posts: n/a

Default Re: Memory leak problem in BerklyDB - 11-03-2006 , 10:13 AM






"pai" <paimailbox (AT) gmail (DOT) com> writes:

Quote:
int db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags);

Here memory will be allocted for the variable *dbp. Now while closing
the DB the corresponding handler also should be destroyed, otherwise it
will lead to a memory leak.

Now my query is that is there any interface to destroy the handler
created by funtion db_create? if there is no interface then where
BerklyDB will release this memory?
I expect the memory to be released when I call (*dbp)->close(*dbp)
to close the handle. And I'd call it a bug in BDB when this does
not happen. Do you have evidence for such a bug? Why would/should
there be a different interface?

best regards
Patrick


Reply With Quote
  #3  
Old   
pai
 
Posts: n/a

Default Re: Memory leak problem in BerklyDB - 11-04-2006 , 08:59 AM




Patrick Schaaf wrote:
Quote:
"pai" <paimailbox (AT) gmail (DOT) com> writes:

int db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags);

Here memory will be allocted for the variable *dbp. Now while closing
the DB the corresponding handler also should be destroyed, otherwise it
will lead to a memory leak.

Now my query is that is there any interface to destroy the handler
created by funtion db_create? if there is no interface then where
BerklyDB will release this memory?

I expect the memory to be released when I call (*dbp)->close(*dbp)
to close the handle. And I'd call it a bug in BDB when this does
not happen. Do you have evidence for such a bug? Why would/should
there be a different interface?

best regards
Patrick

Hi,

As you said the memory might be released during db->close..

Now coming to the interface requirement, whenever we call the interface
for creating some object like CREATE(&pObj) then also we look for it's
destructor like DESTROY(pObj). If the interfaces are provided like this
then then there won't be any confusion, but in berkly this is not
followed, db->close might be releasing the memory which is not
allocated in db->open.
This way of providing the interface will create the ambiguity.

"Once the memory is allocted then it's deallocation point must be
cleary defined"



with regards,
Pai



Reply With Quote
  #4  
Old   
Patrick Schaaf
 
Posts: n/a

Default Re: Memory leak problem in BerklyDB - 11-05-2006 , 01:18 PM



"pai" <paimailbox (AT) gmail (DOT) com> writes:

Quote:
As you said the memory might be released during db->close..
So you don't say that you have any evidence to the contrary. Good.

Quote:
Now coming to the interface requirement, whenever we call the interface
for creating some object like CREATE(&pObj) then also we look for it's
destructor like DESTROY(pObj).
And here the destructor is called pObj->close.

If you don't like that syntax, write a single line trivial wrapper function.

Quote:
then then there won't be any confusion, but in berkly this is not
followed, db->close might be releasing the memory which is not
allocated in db->open.
Of course it might, and it should, as a quality of implementation issue.
db->close should release any memory associated with that open db handle,
be it allocated during db_create, db->open, or any other operation on
the db handle.

Quote:
This way of providing the interface will create the ambiguity.
I don't see any ambiguity.

best regards
Patrick


Reply With Quote
  #5  
Old   
Philip Guenther
 
Posts: n/a

Default Re: Memory leak problem in BerklyDB - 11-05-2006 , 07:05 PM



On Nov 3, 5:30 am, "pai" <paimail... (AT) gmail (DOT) com> wrote:
....
Quote:
Bellow interface will be called for creating the DB handler,
int db_create(DB **dbp, DB_ENV *dbenv, u_int32_t flags);
....
Now my query is that is there any interface to destroy the handler
created by funtion db_create? if there is no interface then where
BerklyDB will release this memory?
This is answered by the official C API documentation found at

http://www.oracle.com/technology/doc...i_c/frame.html

In particular, the page for the db_create() function, found at

http://www.oracle.com/technology/doc.../db_class.html
says:
The db_create function creates a DB structure that is the handle
for a Berkeley DB database. This function allocates memory for
the structure, returning a pointer to the structure in the memory
to which dbp refers. To release the allocated memory and discard
the handle, call the DB->close, DB->remove, DB->rename, or
DB->verify methods.


Philip Guenther



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.