diff --git a/src/engine.c b/src/engine.c
index 52a2e13c0f981a973b7f1fedd4621127c916d70c..05b1e937b7a14bca73be74d4d7a05aba62361c76 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -1007,7 +1007,8 @@ void engine_repartition(struct engine *e) {
 
   /* Partitioning requires copies of the particles, so we need to reduce the
    * memory in use to the minimum, we can free the sorting indices and the
-   * tasks as these will be regenerated at the next rebuild. */
+   * tasks as these will be regenerated at the next rebuild. Also the foreign
+   * particle arrays can go as these will be regenerated in proxy exchange. */
 
   /* Sorting indices. */
   if (e->s->cells_top != NULL) space_free_cells(e->s);
@@ -1015,6 +1016,9 @@ void engine_repartition(struct engine *e) {
   /* Task arrays. */
   scheduler_free_tasks(&e->sched);
 
+  /* Foreign parts. */
+  space_free_foreign_parts(e->s);
+
   /* Now comes the tricky part: Exchange particles between all nodes.
      This is done in two steps, first allreducing a matrix of
      how many particles go from where to where, then re-allocating
diff --git a/src/space.c b/src/space.c
index 9161e578d0afca018caf28e4d5118ccbce08cd01..120f95c80e19c15ecca77f1ece1f30c806fe11a5 100644
--- a/src/space.c
+++ b/src/space.c
@@ -294,6 +294,8 @@ void space_rebuild_recycle_mapper(void *map_data, int num_elements,
 
 /**
  * @brief Free up any allocated cells.
+ *
+ * @param s The #space.
  */
 void space_free_cells(struct space *s) {
 
@@ -308,6 +310,32 @@ void space_free_cells(struct space *s) {
             clocks_getunit());
 }
 
+/**
+ * @brief Free any memory in use for foreign particles.
+ *
+ * @param s The #space.
+ */
+void space_free_foreign_parts(struct space *s) {
+
+#ifdef WITH_MPI
+  if (s->parts_foreign != NULL) {
+    free(s->parts_foreign);
+    s->size_parts_foreign = 0;
+    s->parts_foreign = NULL;
+  }
+  if (s->gparts_foreign != NULL) {
+    free(s->gparts_foreign);
+    s->size_gparts_foreign = 0;
+    s->gparts_foreign = NULL;
+  }
+  if (s->sparts_foreign != NULL) {
+    free(s->sparts_foreign);
+    s->size_sparts_foreign = 0;
+    s->sparts_foreign = NULL;
+  }
+#endif
+}
+
 /**
  * @brief Re-build the top-level cell grid.
  *
diff --git a/src/space.h b/src/space.h
index 924c3efaf81f88cb82a8c23707d42883832aa071..272ee41c3569cf3580678c0de885a41075f0e1b4 100644
--- a/src/space.h
+++ b/src/space.h
@@ -329,6 +329,8 @@ void space_reset_task_counters(struct space *s);
 void space_clean(struct space *s);
 void space_free_cells(struct space *s);
 
+void space_free_foreign_parts(struct space *s);
+
 void space_struct_dump(struct space *s, FILE *stream);
 void space_struct_restore(struct space *s, FILE *stream);
 void space_write_cell_hierarchy(const struct space *s);