Home
Reply
New Visitor
zjuMike
Posts: 5

5m memory leak?why? (api_del_entity caused)

he following simple code of ACIS seems having 5m memory leak?why?

 

can someone help?

 

 

void TestIt()
{
 for (int j = 0; j < 3000; j++)
 {
  SPAposition pos1(0,0,0);
  SPAposition pos2(10,10,10);
  BODY* pBody2 = NULL;
  api_solid_block(pos1, pos2, pBody2);
  if (pBody2)
  {
   api_del_entity(pBody2);
   pBody2 = NULL;
  }
 }
}

New Visitor
zjuMike
Posts: 5

Re: 5m memory leak?why? (api_del_entity caused)

什么原因呢?

什么原因呢?

什么原因呢?

什么原因呢?

什么原因呢?

New Visitor
zjuMike
Posts: 5

Re: 5m memory leak?why? (api_del_entity caused)

The above code is tested on ACIS 13.0. Thanks.

Spatial Moderator
ybiyani
Posts: 223

Re: 5m memory leak?why? (api_del_entity caused)

We have tested a similar code earlier and did not find memory leaks...However after further probing what we learnt that customers were concerned about the process memory increasing inspite of deleting the entity. They may be due to the following

 

1)By default the ACIS history manager is on...so every change you make to the body is stored in the bulletin board...In this case there is create and delete bulletin. Please see http://doc.spatial.com/r19/index.php/Bulletin_Board 

 

2) In debug build the annotations are on by default...so if you are seeing this in then that can be another reason for this behavior.Please see http://doc.spatial.com/r19/index.php/Option:Annotations

 

Here is the list of discussion on similar topics.

http://forums.spatial.com/t5/forums/searchpage/board-id/ACIS/tab/message?q=memory#message-list

 

In addition to that please note R13 is no longer a supported version by Spatial. Please upgrade to R19SP3.

 

 

New Visitor
zjuMike
Posts: 5

Re: 5m memory leak?why? (api_del_entity caused)

Thanks for ybiyani. It is solved. 非常感谢!

 

The following 3 line codes are the most important in the following program.

 

 api_set_int_option("annotations", 0); //seems it does not function. maybe because of degbug mode
 api_logging (0);

 api_clear_annotations();

void TestIt()
{
 for (int j = 0; j < 3000; j++)
 {
  SPAposition pos1(0,0,0);
  SPAposition pos2(10,10,10);
  BODY* pBody2 = NULL;

  api_solid_block(pos1, pos2, pBody2);
  if (pBody2)
  {
   AcisOptions o;
   api_del_entity(pBody2, &o);
   pBody2 = NULL;
   api_clear_annotations();
  }
 }
}

int main(int argc, char* argv[])
{
 api_start_modeller(0);
 api_initialize_kernel();

 api_set_int_option("annotations", 0);
 api_logging (0);

 TestIt();

 api_terminate_kernel();
 api_stop_modeller();

 return 0;
}

Contributor
Sarvnaz
Posts: 25

Re: 5m memory leak?why? (api_del_entity caused)

One thing to note is that when api_logging is set to FALSE, it means that the application is now taking responsibility of managing the entities created through the entitie's life cycle. So, to avoid memory leaks in this case, it becomes very crucial for the application to call api_del_entity or api_del_entity_list to free up the memory. Where as if the api_logging is TRUE, ACIS automatically manages the memory used by each entity created.