Skip to content

Commit

Permalink
Free memory for the correct variable (#1627)
Browse files Browse the repository at this point in the history
Otherwise, memory of project_scratch is leaking and gradient_norm_scratch use will cause problems.
  • Loading branch information
kwalcock committed Jan 17, 2021
1 parent 0781dea commit 13eb330
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dynet/model.cc
Expand Up @@ -272,7 +272,7 @@ void ParameterCollectionStorage::project_weights(float radius) {
auto scratch_size = all_params.size() * sizeof(float);
if (project_scratch == nullptr || sizeof(project_scratch) < scratch_size) {
if (project_scratch != nullptr) {
default_device->mem->free(gradient_norm_scratch);
default_device->mem->free(project_scratch);
}
project_scratch = (float *) default_device->mem->malloc(scratch_size);
}
Expand Down

0 comments on commit 13eb330

Please sign in to comment.