Skip to main content

Summary This article describes a cause of a memory leak in an Orbix 3.3.10 and earlier C based server application
Article Number 28665
Environment Orbix 3.3.10 C All Supported Operating Systems
Question/Problem Description Memory leak in Orbix 3.3 C based server application
Clarifying Information
Error Message
Defect/Enhancement Number ORBTHREE-934
Cause The Orbix 3.3.10 IDL compiler does not generate delete statements in the generated server skeleton code for operations with more than one out parameter. This leads to a memory leak in the server application.

Below is an example of a case where this issue occurs.
The IDL:
struct MessageParsMapStruct
{
    long itsParsNumber;
    string itsString;
};
typedef sequence<MessageParsMapStruct> MessageParsMap;

struct DateTimeStruct
{
    short itsYear;
    short itsMonth;
    short itsDay;
    short itsHour;
    short itsMinute;
    short itsSecond;
    short itsMs;
};

struct MessageStruct
{
    string itsName;
    long itsNumber;
    long itsCount;
    string itsFile;
    long itsLine;
    short itsSeverity;
    string itsRawText;
    DateTimeStruct itsDateTime;
    long itsSequenceNumber;
    MessageParsMap itsPars;
    boolean itsComp[10];
};

typedef sequence<MessageStruct> MessageList;
typedef sequence<char> Block;

// IDL method
boolean readTest(out Block a, out MessageList b)


The server skeleton code that handles the readTest() IDL operation looks like the following:

if (IT_s == 1) { // readTest

    <snipped all dispatching code...>

        IT_result = ((IDL_MODULE_NAME::IDL_INTERFACE_NAME*)IT_pp)->readTest ( a, b, IT_env);

    <snipped more>

    delete b;
    return 1;
}

The code above calls the implementation of readTest() with parameters a and b, where a is of IDL type Block and b is of IDL type MessageList.

The issue is that on leaving the block, only b is getting deleted.

A defect in the IDL compiler is causing to not write out a "delete a;" statement to deallocate the Block out parameter.
Resolution This defect has been logged under defect number ORBTHREE-934. A fix for this is available in Orbix 3.3.11 and all later versions.
Workaround If such a case is being experienced the server skeleton code that handles the readTest() IDL operation should be manually changed with the missing delete statement and then recompiled.
if (IT_s == 1) { // readTest

    <snipped all dispatching code...>

        IT_result = ((IDL_MODULE_NAME::IDL_INTERFACE_NAME*)IT_pp)->readTest ( a, b, IT_env);

    <snipped more>

    // MANUALLY ADD BELOW LINE AS WORKAROUND
    delete a;

   
    delete b;

    return 1;
}
Notes Please note that the manual changes are overridden if the IDL gets compiled again with the IDL compiler.

Please also note that generated code should never be changed manually.

If an issue is encountered with the code generated by the IDL compiler, a support case should be opened with Micro Focus Software in order to have the defect fixed.
Attachment

Created date: 14 February 2012
Last Modified: 05 July 2012
Last Published: 26 June 2012
First Published date: 14 February 2012

#Orbix
#KnowledgeDocs