------------------------------------------------------------------------------
| 559 | |
| 560 | //------------------------------------------------------------------------------ |
| 561 | void vtkObjectManager::PruneUnusedObjects() |
| 562 | { |
| 563 | // Find strong objects not referenced by states |
| 564 | vtkMarshalContext::StrongObjectStore staleStrongObjects; |
| 565 | for (const auto& iter : this->Context->StrongObjects()) |
| 566 | { |
| 567 | for (const auto& object : iter.second) |
| 568 | { |
| 569 | auto identifier = this->Context->GetId(object); |
| 570 | auto key = vtk::to_string(identifier); |
| 571 | if (!this->Context->States().contains(key)) |
| 572 | { |
| 573 | staleStrongObjects[iter.first].insert(object); |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | for (auto& iter : staleStrongObjects) |
| 578 | { |
| 579 | for (const auto& object : iter.second) |
| 580 | { |
| 581 | vtkVLog(this->GetObjectManagerLogVerbosity(), |
| 582 | << "Remove stale strong object: " << iter.first << ":" << object); |
| 583 | this->Context->Retire(iter.first, object); |
| 584 | } |
| 585 | } |
| 586 | staleStrongObjects.clear(); |
| 587 | // Clear out stale weak references to objects |
| 588 | std::vector<vtkTypeUInt32> staleIds; |
| 589 | staleIds.reserve(this->Context->WeakObjects().size()); |
| 590 | for (const auto& iter : this->Context->WeakObjects()) |
| 591 | { |
| 592 | if (iter.second == nullptr) |
| 593 | { |
| 594 | staleIds.emplace_back(iter.first); |
| 595 | vtkVLog(this->GetObjectManagerLogVerbosity(), << "Remove stale object: " << iter.first); |
| 596 | } |
| 597 | } |
| 598 | for (const auto& identifier : staleIds) |
| 599 | { |
| 600 | this->Context->UnRegisterObject(identifier); |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | //------------------------------------------------------------------------------ |
| 605 | void vtkObjectManager::PruneUnusedBlobs() |
no test coverage detected