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(mem): address memory leak related to the MemoryStore #1953

Merged
merged 4 commits into from
Jul 23, 2024
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
4 changes: 2 additions & 2 deletions src/Utilities/Memory/MemoryContainerIterator.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/Utilities/Memory/MemoryManagerExt.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/Utilities/Memory/MemoryStore.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module MemoryStoreModule

type :: MemoryStoreType
private
type(PtrHashTableType), private :: container
type(PtrHashTableType) :: container
contains
procedure :: iterator
procedure :: add
Expand All @@ -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
Expand Down
Loading