Generate large amounts of AcDbText, then AutoCAD show fatal error

Generate large amounts of AcDbText, then AutoCAD show fatal error

Anonymous
Not applicable
1,962 Views
10 Replies
Message 1 of 11

Generate large amounts of AcDbText, then AutoCAD show fatal error

Anonymous
Not applicable

when I create three million AcDbText and add them to model space, in this process, AutoCAD show fatal error warning, then AutoCAD collapse.

 

why?, what can i do for this?

0 Likes
1,963 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable

put your code here. It can be your bug.

0 Likes
Message 3 of 11

Anonymous
Not applicable

BOOL AddToModelSpace(AcDbEntity *pEnt)
{
 if(pEnt == NULL)
    return FALSE;

 AcDbBlockTable *pTable = NULL;
 Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()->getBlockTable(pTable, AcDb::kForRead);
 
 AcDbBlockTableRecord *pRecd = NULL;
 es = pTable->getAt(ACDB_MODEL_SPACE, pRecd, AcDb::kForWrite);
 es = pRecd->appendAcDbEntity(pEnt);
 
 pTable->close();
 pRecd->close();
 pEnt->close();

 return TRUE;
}

 

 

void cmdTest()
{

   for(long m=0L; m<1500L; m++){
       for(long j=0L; j<2000L; j++){

          AcDbText *pText = new AcDbText(AcGePoint3d(m*100,j*100,0), _T("abc")); 

          pText->setColorIndex(1);  

          if(AddToModelSpace(pText)==FALSE){
            if(pText != NULL)
               delete pText;
         }
     }
  }

}

0 Likes
Message 4 of 11

Anonymous
Not applicable

your code works fine, BUT...

when it was done 86%, I got a message, that I have not enough memory to complete task.

So, I think that your computer is not good enough for this task such as my 🙂 

 

PS: I didn't got a fatal error at all

 

AcApDocument * pDoc = acDocManager->mdiActiveDocument();
acDocManager->lockDocument(pDoc);
acedSetStatusBarProgressMeter(_T("Press ESC to abort: "), 0, 1500);
for(long m=0L; m<1500L; m++)
{
   for(long j=0L; j<2000L; j++)
   {
      AcDbText *pText = new AcDbText(AcGePoint3d(m*100,j*100,0), _T("abc")); 
      pText->setColorIndex(1);  

      if(AddToModelSpace(pText)==FALSE)
      {
          if(pText != NULL)
            delete pText;
      }
   }
   acedSetStatusBarProgressMeterPos( m );
   if(acad_abortCycle(_T("\nINFO: aborted...")) == 1)
      break;
}
acedRestoreStatusBar();
acDocManager->unlockDocument(pDoc);

 

int acad_abortCycle(const ACHAR * abortString)
{
   int res = 0;
   CWinApp *app = acedGetAcadWinApp();
   CWnd *wnd = app->GetMainWnd ();
   MSG msg; 
   while (:: PeekMessage (&msg, wnd->m_hWnd, 0, 0, PM_NOREMOVE)) 
   { 
      if (!app->PumpMessage()) 
      { 
         :: PostQuitMessage(0); 
            break; 
      } 
   } 
   LONG lIdle = 0;
   while (app->OnIdle (lIdle++));

   res = acedUsrBrk();
   if(res == 1 && abortString != NULL) acutPrintf(abortString);
   return res;
}

 

 

Message 5 of 11

Anonymous
Not applicable

How much capacity in your computer memory?

0 Likes
Message 6 of 11

Anonymous
Not applicable

2GB.

But free memory, that can be used is little more then 1.2GB (Windows, antivirus, e.t.c eat 800MB)

0 Likes
Message 7 of 11

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

try to turn off UNDO-recording, that will save a lot of memory as AutoCAD does not need to save every single add-task.

_UNDO _AUTO _OFF

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 8 of 11

Anonymous
Not applicable

when it was done 59%, I got a fatal error message .

if I stop at 58%, then all AcDbText are created in  model space, But if click "ZOOM" or "REGEN" in command line, AutoCAD show fatal error and collapse.  It looks like refresh graphics display make it.

0 Likes
Message 9 of 11

Anonymous
Not applicable

did you test this in pure autocad? if no, try to unload everything additional (arx-files, lisp and so on) and leave just pure acad, like after installation. I didn't get fatal error. It was a messagebox with Ok|Cancel buttons for aborting the task. So, the problem can be in other arx file :), if it has, db  reactor, for example.

And what about Alfred's advice? It will reduce the memory usage.

 

PS: try to do the same with, for example, points or lines (to check is this text bug or just lack of memory)

PS: if it was a pure autocad, may be it's time to reinstall it 🙂

0 Likes
Message 10 of 11

Anonymous
Not applicable

in pure autocad, it outputs more AcDbText, but cmmand "zoom" and "regen" still lead to error or enough memory .

turn off UNDO-recording, not solve the problem.

points or lines has no problem.

 

It looks like  lack of memory, I'm not sure.

 

0 Likes
Message 11 of 11

sdphg
Enthusiast
Enthusiast

sorry for previous empty reply.

put the open and close BlockTable operations inside the loop is not a good idea.those operations costly. you should put those codes outside the loop,my suggestion may not the right answer,but it's worth to try.Smiley Tongue

0 Likes