diff --git a/src/Utilities/Memory/MemoryContainerIterator.f90 b/src/Utilities/Memory/MemoryContainerIterator.f90 index bad175bf602..f9169a1d35a 100644 --- a/src/Utilities/Memory/MemoryContainerIterator.f90 +++ b/src/Utilities/Memory/MemoryContainerIterator.f90 @@ -29,10 +29,10 @@ module MemoryContainerIteratorModule !! !< function constructor(container_iterator) result(iterator) - class(IteratorType) :: container_iterator + class(IteratorType), allocatable :: container_iterator type(MemoryContainerIteratorType) :: iterator - iterator%container_iterator = container_iterator + call move_alloc(container_iterator, iterator%container_iterator) end function constructor diff --git a/src/Utilities/Memory/MemoryManagerExt.f90 b/src/Utilities/Memory/MemoryManagerExt.f90 index 00d61b7ebe7..255c745e738 100644 --- a/src/Utilities/Memory/MemoryManagerExt.f90 +++ b/src/Utilities/Memory/MemoryManagerExt.f90 @@ -46,6 +46,7 @@ subroutine memorystore_remove(component, subcomponent, context) if (mt%path == memory_path .and. mt%mt_associated()) then call mt%mt_deallocate() removed = .true. + deallocate (itr) exit end if end do diff --git a/src/Utilities/Memory/MemoryStore.f90 b/src/Utilities/Memory/MemoryStore.f90 index 4a7664770af..93a7a40e6fc 100644 --- a/src/Utilities/Memory/MemoryStore.f90 +++ b/src/Utilities/Memory/MemoryStore.f90 @@ -12,7 +12,7 @@ module MemoryStoreModule type :: MemoryStoreType private - type(PtrHashTableType), private :: container + type(PtrHashTableType) :: container contains procedure :: iterator procedure :: add @@ -27,11 +27,13 @@ module MemoryStoreModule !! !< function iterator(this) result(itr) - ! -- dummy class(MemoryStoreType) :: this type(MemoryContainerIteratorType) :: itr + ! -- local + class(IteratorType), allocatable :: container_iterator - itr = MemoryContainerIteratorType(this%container%Iterator()) + allocate (container_iterator, source=this%container%iterator()) + itr = MemoryContainerIteratorType(container_iterator) end function !> @brief Add a MemoryType to the container