How do I free the memory used from node_load()?
It happens because node_load(), as every Drupal function that loads entities from the database, stores in memory the loaded entity. If you want to avoid that happens, you can use code similar to the following one.

for ($i = 0; $i &lt; 1000000; $i++) {
  $nid = get_node_id($i);
  $node = entity_load('node', array($nid), array(), TRUE);
  $data = [
    $node-&gt;field_1,
    $node-&gt;field_3,
  ];
  save_to_database($data);
}


The last argument of entity_load() is telling Drupal not to store in memory cache the previously loaded entity.

This is what happens with the default entity controller implemented from Drupal, DrupalDefaultEntityController, which uses the following code for DrupalDefaultEntityController::resetCache().

public function resetCache(array $ids = NULL) {
  if (isset($ids)) {
    foreach ($ids as $id) {
      unset($this-&gt;entityCache[$id]);
    }
  }
  else {
    $this-&gt;entityCache = array();
  }
}