Skip to content

Commit

Permalink
Fixed Memory leak in Population due to dangling views (anyoptimizatio…
Browse files Browse the repository at this point in the history
  • Loading branch information
blankjul committed Jul 9, 2023
1 parent 54ad49d commit 6e0f97c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pymoo/core/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def set(self, *args, **kwargs):

for i in range(len(self)):
val = values[i] if is_iterable else values

# check for view and make copy to prevent memory leakage (#455)
if isinstance(val, np.ndarray) and not val.flags["OWNDATA"]:
val = val.copy()

self[i].set(key, val)

return self
Expand Down

0 comments on commit 6e0f97c

Please sign in to comment.