Message 1 of 1
Problems with Object Data Reading (possible memory leak?)
Not applicable
03-04-2003
06:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I have a problem.
I created a function that I call when I need particular data from Object
Data records (ReadOD function at the end of the post).
Basicly I go throug all the Records and search for a particular column. Is
there any other way? Maybe some kind of function to do this is already
written?
Then I call this function in the loop (4 times each iteration)...that's
about 1000 to 10000 per file and there are about 50 files in the loop
alltogether. I found out that it consumes a lot of memory when I run ReadOD
a lot (like 2GB at the end of processing...). What am I doing wrong? Can I
read ObjectData some other way?
if( (i=acedSSGet("A", NULL, NULL, NULL, vname)) != RTNORM )
{
return;
}
if( acedSSLength(vname, &l) < 0)
l = 0;
for(i=0; i
{
acedSSName( vname, i, ename);
acdbGetObjectId( idXDataEntity, ename );
ReadOD( idXDataEntity, "SIFKO", sifko);
ReadOD( idXDataEntity, "STEV", stev);
ReadOD( idXDataEntity, "PODD", podd);
ReadOD( idXDataEntity, "PARCELA", parcela);
}
int CObjectData::ReadOD( AcDbObjectId eId, char *asColumn, char *asRez )
{
AcMapSession *mapApi = NULL;
AcMapProject *pProj = NULL;
AcMapODContainer *pODCont = NULL;
AcMapODRecordIterator *pIter = NULL;
AcMapODTableRecord record;
AcMapODTable *pTable = NULL;
char * colname = NULL;
strcpy( asRez, "" );
int iRez = 0;
// Create an AutoCAD Map session and get the top level objects.
//
mapApi = AcMapGetSession();
mapApi->GetProject(pProj);
pProj->GetODContainer(pODCont);
pODCont->GetObjectODRecordIterator (pIter);
int err = pIter->Init (eId, AcMap::kOpenForRead, Adesk::kFalse);
for (; pIter->IsDone() == Adesk::kFalse; pIter->Next())
{
pIter->GetRecord (record);
int irrr02 = pODCont->GetODTable ( pTable, record.ODTableName());
char sTmp1[50], sTmp2[50];
AcMapODTableDefinition tableDef = pTable->Definition();
AcMapODColumnDefinition Column;
for (int i = 0; i < record.Count(); i++)
{
tableDef.GetColumn( Column, i );
strcpy( sTmp1, asColumn );
strcpy( sTmp2, Column.Name() );
strupr( sTmp1 );
strupr( sTmp2 );
if( strcmp( sTmp1, sTmp2 ) == 0 )
{
AcMapValue &val = record.Value(i);
strcpy( asRez, ((const char *)val) );
iRez = 1;
break;
}
}
if (pTable) delete pTable;
}
if (pIter) delete pIter;
return iRez;
}
I have a problem.
I created a function that I call when I need particular data from Object
Data records (ReadOD function at the end of the post).
Basicly I go throug all the Records and search for a particular column. Is
there any other way? Maybe some kind of function to do this is already
written?
Then I call this function in the loop (4 times each iteration)...that's
about 1000 to 10000 per file and there are about 50 files in the loop
alltogether. I found out that it consumes a lot of memory when I run ReadOD
a lot (like 2GB at the end of processing...). What am I doing wrong? Can I
read ObjectData some other way?
if( (i=acedSSGet("A", NULL, NULL, NULL, vname)) != RTNORM )
{
return;
}
if( acedSSLength(vname, &l) < 0)
l = 0;
for(i=0; i
acedSSName( vname, i, ename);
acdbGetObjectId( idXDataEntity, ename );
ReadOD( idXDataEntity, "SIFKO", sifko);
ReadOD( idXDataEntity, "STEV", stev);
ReadOD( idXDataEntity, "PODD", podd);
ReadOD( idXDataEntity, "PARCELA", parcela);
}
int CObjectData::ReadOD( AcDbObjectId eId, char *asColumn, char *asRez )
{
AcMapSession *mapApi = NULL;
AcMapProject *pProj = NULL;
AcMapODContainer *pODCont = NULL;
AcMapODRecordIterator *pIter = NULL;
AcMapODTableRecord record;
AcMapODTable *pTable = NULL;
char * colname = NULL;
strcpy( asRez, "" );
int iRez = 0;
// Create an AutoCAD Map session and get the top level objects.
//
mapApi = AcMapGetSession();
mapApi->GetProject(pProj);
pProj->GetODContainer(pODCont);
pODCont->GetObjectODRecordIterator (pIter);
int err = pIter->Init (eId, AcMap::kOpenForRead, Adesk::kFalse);
for (; pIter->IsDone() == Adesk::kFalse; pIter->Next())
{
pIter->GetRecord (record);
int irrr02 = pODCont->GetODTable ( pTable, record.ODTableName());
char sTmp1[50], sTmp2[50];
AcMapODTableDefinition tableDef = pTable->Definition();
AcMapODColumnDefinition Column;
for (int i = 0; i < record.Count(); i++)
{
tableDef.GetColumn( Column, i );
strcpy( sTmp1, asColumn );
strcpy( sTmp2, Column.Name() );
strupr( sTmp1 );
strupr( sTmp2 );
if( strcmp( sTmp1, sTmp2 ) == 0 )
{
AcMapValue &val = record.Value(i);
strcpy( asRez, ((const char *)val) );
iRez = 1;
break;
}
}
if (pTable) delete pTable;
}
if (pIter) delete pIter;
return iRez;
}