Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak with ResetKernel #2520

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nestkernel/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ Model::create( thread t )
{
assert( ( size_t ) t < memory_.size() );
Node* n = create_();
memory_[ t ].push_back( n );
memory_[ t ].emplace_back( n );
return n;
}

Expand Down
14 changes: 4 additions & 10 deletions nestkernel/node_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,18 +568,12 @@ NodeManager::destruct_nodes_()
{
#pragma omp parallel
{
index t = kernel().vp_manager.get_thread_id();
SparseNodeArray::const_iterator n;
for ( n = local_nodes_[ t ].begin(); n != local_nodes_[ t ].end(); ++n )
const index tid = kernel().vp_manager.get_thread_id();
for ( auto node : local_nodes_[ tid ] )
{
// We call the destructor for each node excplicitly. This
// destroys the objects without releasing their memory. Since
// the Memory is owned by the Model objects, we must not call
// delete on the Node objects!
n->get_node()->~Node();
delete node.get_node();
}

local_nodes_[ t ].clear();
local_nodes_[ tid ].clear();
} // omp parallel
}

Expand Down