Discussion:
[omniORB] Request for assistance with server side memory leak (omniORB 4.1.3)
Mark Ferguson
2010-06-01 04:25:17 UTC
Permalink
Hi,


We are seeking advise on how to resolve a server-side memory leak with omniORB 4.1.3

Symptom observed:


- The response buffer allocated by the server is never freed


Seaking advise on:

- What we need to change to ensure that the server does not leak memory


Summary of software used:


- Client (1) implementation omniORB 2.8 (win32)
- Client (2) implementation omniORB 4.1.3 (AIX 5.3)
- Server implementation omniORB 4.1.3 (AIX 5.3)

Note: Changing the win32 client implementation is not an option at this stage.



IDL Summary:

Service.idl

long getChildrenList(in string req_data,
in long req_data_len,
out string response_data,
out long response_data_len)
raises (EInternalError, EGetChildrnListFailed);

ServiceSK.cc

::CORBA::Long _objref_Service::getChildrenList(const char* req_data, ::CORBA::Long req_data_len, ::CORBA::String_out response_data, ::CORBA::Long& response_data_len)



Client side summary:

void * _outBuf;
char * reply;

...
CORBA::Object_var obj = orb->string_to_object(szIOR);
Service_var connVar = Service::_narrow(obj);
...
{
// the corba system may soon alloc a new output buffer,
// free the current one if it exists
CORBA::string_free((char *) _outBuf);
...
connVar -> getChildrenList ((char *)_inBuf, _inBufSize, reply, outBufSize);
_outBuf = reply;
...
}


Server side summary:

Service_i.cpp

CORBA::Long Service_i::getChildrenList (const char *req_data,
CORBA::Long req_data_len,
CORBA::String_out response_data,
CORBA::Long &response_data_len)
{
....
CORBA::Long ret = serverImplGetChildrenList(req_data, req_data_len, response_data, response_data_len, resv );
...
}

ServerImpl.cpp

int serverImplGetChildrenList( const char * request_data,
long request_data_len,
char * & response_data, // should this be CORBA::String_var & response_data, or is there more required?
long & response_data_len,
char* reserved)
{
...
// allocate memory for the response on the heap
response_data = new char [1024000];

// populate the response buffer with data
...
return SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20100531/93a1e253/attachment.htm
Brian Neal
2010-06-01 05:20:33 UTC
Permalink
Post by Mark Ferguson
Hi,
We are seeking advise on how to resolve a server-side memory leak with
omniORB 4..1.3
- The response buffer allocated by the server is never freed
- What we need to change to ensure that the server does not leak memory
- Client (1) implementation omniORB 2.8 (win32)
- Client (2) implementation omniORB 4.1.3 (AIX 5.3)
- Server implementation omniORB 4.1.3 (AIX 5.3)
Note: ?Changing the win32 client implementation is not an option at this
stage.
Service.idl
??long getChildrenList(in string req_data,
?? ? ? ? ? ? ? ? ? ? ? in long req_data_len,
?? ? ? ? ? ? ? ? ? ? ? out string response_data,
?? ? ? ? ? ? ? ? ? ? ? out long response_data_len)
?? ? ? ? ? raises (EInternalError, EGetChildrnListFailed);
ServiceSK.cc
::CORBA::Long _objref_Service::getChildrenList(const char* req_data,
::CORBA::Long req_data_len, ::CORBA::String_out response_data,
::CORBA::Long& response_data_len)
[..]
Post by Mark Ferguson
Service_i.cpp
CORBA::Long ?Service_i::getChildrenList (const char ?*req_data,
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CORBA::Long ?req_data_len,
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CORBA::String_out response_data,
?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CORBA::Long ?&response_data_len)
{
...
CORBA::Long ret = serverImplGetChildrenList(req_data, req_data_len,
response_data, response_data_len, resv );
...
}
ServerImpl.cpp
int serverImplGetChildrenList( ?const char * request_data,
?? ? ? ? ? ? ? ? ? long request_data_len,
?? ? ? ? ? ? ? ? ? char * & response_data,?// should this be
CORBA::String_var & response_data, or is there more required?
?? ? ? ? ? ? ? ? ? long & response_data_len,
?? ? ? ? ? ? ? ? ? char* reserved)
{
...
// allocate memory for the response on the heap
response_data = new char [1024000];
// populate the response buffer with data
...
return SUCCESS;
}
The first suggestion that pops into my head:

response_data is a CORBA::String_out. You should allocate the memory
with CORBA::string_alloc() because the skeleton code will deallocate
with CORBA::string_free() (and not delete []).

Regards,
BN

Loading...