jzhang0502
December 23rd, 2004, 02:24 PM
I am trying to catch some memory leakage in others code. It is really a suffer.
My question is that the structure array is not given memory using new or malloc, it is given value directly, so do I need to release it?
If I need to do it, how should I do it?
Should I release the field one by one? or something else.
Thank you very much.
Can you please give some sample code about this ??
the code is below:
struct THREAD_PARMS {
// Need change
IClientVirtualDeviceSet *vds;
const char * vdName;
const char * filePath;
bool doCompression ;
int taskId;
int taskScheduleId;
int taskExecId;
JavaVM *vm;
jclass obj ;
jobject execResult;
char* lpInstanceName;
int first;
};
THREAD_PARMS parms[32]; // each thread needs its own parm block
HANDLE children[33]; // 32 is maximum number of streams.
for (ix=0; ix<numFiles; ix++)
{
//get the JVM
JavaVM *vm ;
env->GetJavaVM(&vm) ;
// All threads share the same virtual device set,
// but must operate on different virtual devices.
//
if(lpInstanceName == NULL)
{
//printf("startSecondaries: Default Instance\n");
parms[ix].vds = vds;
parms[ix].vdName = vdNames[ix];
parms[ix].filePath = filePaths[ix];
parms[ix].doCompression = doCompression ;
parms[ix].obj = obj;
parms[ix].taskId = taskId;
parms[ix].taskScheduleId = taskScheduleId;
parms[ix].taskExecId = taskExecId;
parms[ix].vm = vm;
parms[ix].execResult = execResult ;
parms[ix].lpInstanceName = lpInstanceName;
parms[ix].first = 1;
children[ix] = (HANDLE)_beginthreadex (
NULL, 0, runSecondary, (void*)&parms[ix], 0, &threadId);
}
My question is that the structure array is not given memory using new or malloc, it is given value directly, so do I need to release it?
If I need to do it, how should I do it?
Should I release the field one by one? or something else.
Thank you very much.
Can you please give some sample code about this ??
the code is below:
struct THREAD_PARMS {
// Need change
IClientVirtualDeviceSet *vds;
const char * vdName;
const char * filePath;
bool doCompression ;
int taskId;
int taskScheduleId;
int taskExecId;
JavaVM *vm;
jclass obj ;
jobject execResult;
char* lpInstanceName;
int first;
};
THREAD_PARMS parms[32]; // each thread needs its own parm block
HANDLE children[33]; // 32 is maximum number of streams.
for (ix=0; ix<numFiles; ix++)
{
//get the JVM
JavaVM *vm ;
env->GetJavaVM(&vm) ;
// All threads share the same virtual device set,
// but must operate on different virtual devices.
//
if(lpInstanceName == NULL)
{
//printf("startSecondaries: Default Instance\n");
parms[ix].vds = vds;
parms[ix].vdName = vdNames[ix];
parms[ix].filePath = filePaths[ix];
parms[ix].doCompression = doCompression ;
parms[ix].obj = obj;
parms[ix].taskId = taskId;
parms[ix].taskScheduleId = taskScheduleId;
parms[ix].taskExecId = taskExecId;
parms[ix].vm = vm;
parms[ix].execResult = execResult ;
parms[ix].lpInstanceName = lpInstanceName;
parms[ix].first = 1;
children[ix] = (HANDLE)_beginthreadex (
NULL, 0, runSecondary, (void*)&parms[ix], 0, &threadId);
}