#749 Memory leaks when calling rexx from a c++ DLL

APIs (66)

We are testing Rexx ooRexx-4.0.0-4861 RC.
Test is done on Windows XP SP4.

Each time there is a call to RexxApi from C/C++ program, a new handle is used by program and never
The function tested is RexxQueryMacro and RexxStart.
In version 3.2, memory and Handles are fixed.

See below how we use it (3.2 reference API) :

RXSYSEXIT   vExit[2]={0};               // UserExit pour l'affichage
RXSTRING    *vPtMacro,vMacro[2];        // argument string for REXX macro-space
RXSTRING    vRexxStringRet;             // return value from REXX
SHORT       vRexxRc = 0;                // return code from function
char        vBuffRet[250],              // if too small , le rexx will allocate a new space
USHORT      vPosition,vNbParam; 
int         vRet;

RXSTRING * vTbParam = new RXSTRING [ _NbCde+2 ];

vExit[0].sysexit_name = sNameFonctionExit;
vExit[0].sysexit_code = RXSIO;
vExit[1].sysexit_code = RXENDLST;

ErrCode = RexxStart( vNbParam,          // number of arguments
                vTbParam,           // array of arguments
                RexxFile,           // Name of REXX file ou fonction dans la macro-space
                vPtMacro,           // != NULL si macro-space
                "ROBOT",            // Command env. Name
                RXSUBROUTINE,       // Code for how invoked
                vExit,              // EXITs on this call
                &vRexxRc,           // Rexx program output
                &vRexxStringRet);   // Rexx program output

if ( vRexxStringRet.strptr && vRexxStringRet.strptr != vBuffRet ) { 
    // Rexx has allocated a new buffer
    GlobalFree( vRexxStringRet.strptr);                 // Release storage


  • Anonymous - 2009-07-06

    Moreover, an important point is that memory usage increases at each called of RexxQueryMacro and RexxStart and it is never deallocated.

  • Rick McGuire

    Rick McGuire - 2009-07-06

    If you can, please provide a working program we can use to recreate/debug this problem.

  • Anonymous - 2009-07-06

    Complete Sample

  • Anonymous - 2009-07-06

    You will find enclosed a complete sample (display 'Cv Hello') that call rexxStart, and the associated CvHello.exe
    To reproduce :
    Set Hello.rex in C:\ Launch the CvHello.exe or debug it with viual.
    At each call you'll see memory and handle increasing.
    I think memory leaks is due to parameter parsing.
    If RexxStart is called with only function name memory is stable.

  • Rick McGuire

    Rick McGuire - 2009-07-06

    Committed revision 4881.

    The problem with the handles was a real bug, but the memory growth was not a real memory leak, but rather an artifact of how Windows Taskmanager happens to report the working set. The ooRexx memory heap is allocated on the first RexxStart() invocation and is kept active so that subsequent calls do not need to completely rebuild the interpreter environment. As additional portions of this heap are touched by the garbage collector, the apparant working set size appears to grow, but the actual amount of memory that was allocated has not changed.

  • Mark Miesfeld

    Mark Miesfeld - 2010-02-19

    The fix for this item was in the 4.0.0 release.



Cancel  Add attachments