I am saving a lot of entities as part of a script - several thousand.
This is frequently causing out of memory errors.
I've been trying to do something like this:
cache_clear_all(); drupal_flush_all_caches(); $entity = NULL;
After entity save ($entity is the variable for the entity object), but nothing is working.
How do I clear the memory for the past entities? There is no use for it after the entity is saved.