MNT fix memory leak in elkan KMeans
@@ -322,6 +322,9 @@ def _elkan_iter_chunked_dense(
for k in range(n_features):
centers_new[j, k] += centers_new_chunk[j * n_features + k]
+ free(centers_new_chunk)
+ free(weight_in_clusters_chunk)
+
if update_centers:
_relocate_empty_clusters_dense(X, sample_weight, centers_old,
centers_new, weight_in_clusters, labels)
@@ -553,6 +556,9 @@ def _elkan_iter_chunked_sparse(
for k in range(n_features):
centers_new[j, k] += centers_new_chunk[j * n_features + k]
+ free(centers_new_chunk)
+ free(weight_in_clusters_chunk)
+
if update_centers:
_relocate_empty_clusters_sparse(
X_data, X_indices, X_indptr, sample_weight,
