43 views
in Platform Packages by
Hi, EW team:

    The function below in ewobject.c doesn't maintain the link list on which it operates when a node in the link list is marked for Garbage Collector. I wonder if the software at my hand is out of date or anything else?  I haven't seen any version information in my RTE package.

   Thank you.

/* Removes entries for auto objects, which are about to be disposed by the
   Garbage Collector */
static void DisposeAutoObjects( void )
{
  XAutoObjectEntry** entry = &AutoObjects;
  XAutoObjectEntry*  tmp;

  /* Look for entries, which refer to unused objects */
  while ( *entry )
  {
    /* Verify, wheter the affected object has been marked by the Garbage
       Collector - If not, remove the entry */
    if ((*entry)->Object && !(*entry)->Object->_.Mark )
    {
      tmp    = *entry;
      *entry = tmp->Next;
      EwFree( tmp );

      /* Track the RAM usage */
      EwObjectsMemory -= sizeof( XAutoObjectEntry );
    }  

    /* Continue with the next entry in the chain */
    else
      entry = &((*entry)->Next );
  }
}
 

 Best regards.

Stephen

1 Answer

0 votes
by

Hello Stephen,

your version of the function is actual. Please note, this function limits to dispose objects which have not been marked in the past. 

... doesn't maintain the link list on which it operates when a node in the link list is marked for Garbage Collector

Why should the function does it? The link list is created during the mark phase only. Once the mark phase is finished, the link list is not used anymore. During next mark phase new link list is created.

Do you observe an issue with the actual implementation?

Best regards

Paul Banach

by
Hi, Paul:

    I once encountered an issue that the program was blocked in the function FindAutoObject in debug mode. The chance is very rare, so I never see it again. But in runtime, thread running EwProcess() sometimes got blocked. Do you think it's possible the link list was built into a circular one?  According to your description, the link list headed by AutoObjects is highly dynamic. It's created and disposed each time garbage collection is done, right?
 

 Thank you.

/* The following function searches in the list of existing auto objects for
   an object created from the description aAutoObject. If a corresponding
   entry could be found, the function removes it from the list and returns
   it. If the entry could not be found, the function returns 0. */
static XAutoObjectEntry* FindAutoObject( const XAutoObject* aAutoObject )
{
  XAutoObjectEntry** entry = &AutoObjects;

  /* Look for the entry, registered for the object aAutoObject */
  while ( *entry )
  {
    /* The desired entry found? */
    if ((*entry)->Origin == aAutoObject )
    {
      XAutoObjectEntry* tmp = *entry;
      *entry = tmp->Next;

      return tmp;
    }  

    /* Continue with the next entry in the chain */
    else
      entry = &((*entry)->Next );
  }

  return 0;
}

 

BR.

Stephen
by

Do you think it's possible the link list was built into a circular one? 

This should not happen. However we have observed on a particular HW an issue with the CPU cache causing memory read accesses to return old values in very seldom cases. This was observed exactly with the Link variable. May I ask you what HW are you using?

According to your description, the link list headed by AutoObjects is highly dynamic. It's created and disposed each time garbage collection is done, right?

Exactly.

Some additional few ideas:

1. If you are using threads, please note that no EW related code may be called from other threads. Only the GUI thread is allowed to do this. See also Take care in multi-threading environments.

2. When you access Chora objects or strings from the C code, never store (for later use) the pointers referring the data objects in C variables. See also Don't retain nor modify objects or strings.

Best regards

Paul

 

by
Hi, Paul:

I'm using IMXRT1172 with 1MB EW mempool located in OCRAM and 8MB extra mempool in HyperRAM. 512KB uncached OCRAM is used as framebuffer.

I will look into your 2 suggestions above.

Thank you.

 

BR.

Stephen
by
Hi Stephen,

I just spoke to the engineer responsible for the IMXRT platform. According to what he said, we have to analyse the HW configuration more in detail. Since you are customer, would you please contact us directly via support@embedded-wizard.de ?

Best regards

Paul Banach
by
Hi, Paul:

I will send a mail to support@embedded-wizard.de

Thank you.

 

BR.
Stephen
by

Hi, Paul:

     The problem here is finally targeted to the function EwGetAutoObject that is called in other thread, as you suggested See also Take care in multi-threading

     This issue can be closed. Thank you.

  Best regards

Stephen

 

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...