[omniORB] Memory leak related to Proxy Object Factories
Tuyen Chau
tchau at verano.com
Tue Dec 5 17:13:00 GMT 2006
I need some help tracking down what appears to be a memory leak deep in
the proxy object factories (POF), or how they interact with other
components in omniORB. In our application, we derive from the default
POFs to instantiate our own proxies. This all works fine. However,
when we take another step in our proxy object factories and try to cache
our proxies so that there is a unique object reference for each servant,
we ran into a memory leak of about 600-700 bytes, each time our POF is
called.
Here's how we cache the object. We use the key in the omniIdentity to
identify object. If an object has been created for that key, we
increment the reference count on the object and return it. If not, we
create a new object and cache it. Our newObjRef(() function looks
approximately like this,
OurPofClass::newObjRef(omniIOR* ior, omniIdentity* ident) {
unsigned char *key = (unsigned char *)ident->key();
int keySize = ident->keysize();
omniObjRef obj;
obj = FIND_IN_CACHE(key, keySize);
if (obj == NULL) {
obj = new OUR PROXY();
CACHE(obj, key, keySize);
} else {
ClassName::_duplicate(dynamic_cast<ClassName_ptr>(obj));
}
return obj;
}
As far we can tell, there is no leak in our cache implementation, which
really is a hash table. If we comment out just the line of code that
puts the object in the cache, the memory leak is gone. If we put the
object in the cache, the memory leak is back. It seems that omniORB
checks on the return object and do something different if the object is
not "brand new", and that something "different" is causing the memory
leak. But then we are puzzled as to how omniORB can even tell if the
return object is "brand new" vs. cached.
Does this make sense to any of you? Does anyone know how can we fix
this memory leak?
Best regards,
Tuyen
More information about the omniORB-list
mailing list