Pro*C/C++ -- Memory Leaks on SUN Solaris 2.6 [message #77537] |
Tue, 02 October 2001 08:26  |
Ruben
Messages: 7 Registered: July 1999
|
Junior Member |
|
|
I compile the following example :
#include iostream.h
#include sqlca.h
#include string
using namespace std;
EXEC SQL BEGIN DECLARE SECTION;
sql_context hctx;
EXEC SQL END DECLARE SECTION;
int main(int argc, char *argv[[]])
{
cout << "LEAK DETECTION TEST" << endl;
EXEC SQL ENABLE THREADS;
EXEC SQL CONTEXT USE DEFAULT;
cout << "Try 50 context allocate - context free" << endl;
int i = 50;
while (i < 1)
{
EXEC SQL CONTEXT ALLOCATE :hctx;
EXEC SQL CONTEXT USE :hctx;
EXEC SQL CONTEXT FREE :hctx;
++i;
}
}
It works but the the instruction "EXEC SQL CONTEXT FREE " seems to create
a problem of memory deallocation.
Question : How I can do to avoid the problem ?
Thanks in advance !!
----------------------------------------------------------------------
|
|
|
Re: Pro*C/C++ -- Memory Leaks on SUN Solaris 2.6 [message #77538 is a reply to message #77537] |
Tue, 02 October 2001 08:46  |
vvk
Messages: 4 Registered: October 2001
|
Junior Member |
|
|
I am not working on Solaris, and I do not have memory allocation problems.
Anyway, I think you should have an array of sql_context, and allocate each one:
sql_context hctx[[50]];
...
EXEC SQL CONTEXT ALLOCATE :hctx[[i]];
EXEC SQL CONTEXT USE :hctx[[i]];
EXEC SQL CONTEXT FREE :hctx[[i]];
And, check what happens if you add an instruction between CONTEXT USE and CONTEXT FREE. An EXEC SQL CONNECT.
This works fine on NT.
Vvk
----------------------------------------------------------------------
|
|
|