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 ACE_Shared_Memory_Pool #2077

Merged
merged 17 commits into from Jun 21, 2023
Merged

Fix ACE_Shared_Memory_Pool #2077

merged 17 commits into from Jun 21, 2023

Conversation

jwillemsen
Copy link
Member

@jwillemsen jwillemsen commented Jun 16, 2023

The ACE_Shared_Memory_Pool doesn't release the shared memory as it should on release. This leads to an increase of used shared memory on a system where part of the processes are restarted. This can be reproduced by using an OpenDDS test using shared memory where the subscriber keeps running and the publishers are each time restarted. After each restart of the publisher run sudo pmap -p $(pidof subscriber) | grep shmid and notice that the number of shmid mappings only increases.

In high level overview the following operations should be used by ACE:

  • shmget() allocates as much physical memory as you request for the segment.
  • shmat() programs the MMU and sets things up in the kernel so that some address range in your process maps to the segment.
  • shmdt() does the reverse operation and removes the mapping.
  • shmctl() with IPC_RMID deallocates the physical memory of the segment (marks it as free).

Before this PR ACE didn't use shmdt at all, only shmctl was used on release. In order to use shmdt we need to store the addresses returned by shmat and we also need to keep the shmid of the first segment in a member variable as we can't read it from the shared memory segment itself because after calling shmdt we can't read that memory anymore

    * ACE/ace/SV_Shared_Memory.h:
    * ACE/ace/MMAP_Memory_Pool.cpp:
    * ACE/ace/Malloc_T.cpp:
    * ACE/ace/Malloc_T.inl:
    * ACE/ace/Mem_Map.cpp:
    * ACE/ace/Shared_Memory.h:
    * ACE/ace/Shared_Memory_MM.h:
    * ACE/ace/Shared_Memory_Pool.cpp:
    * ACE/ace/Shared_Memory_Pool.h:
…m shared memory segments when we don't use them anymore. At the moment the memory pool is destroyed also let the OS release all resources

    * ACE/ace/Shared_Memory_Pool.cpp:
    * ACE/ace/Shared_Memory_Pool.h:
    * ACE/ace/Shared_Memory_Pool.cpp:
    * ACE/examples/System_V_IPC/SV_Semaphores/Semaphores_2.cpp:
    * ACE/tests/SV_Shared_Memory_Test.cpp:
…ith older ACE versions

    * ACE/ace/Shared_Memory_Pool.cpp:
    * ACE/ace/Shared_Memory_Pool.h:
ACE/ace/Shared_Memory_Pool.cpp Show resolved Hide resolved
ACE/ace/Shared_Memory_Pool.h Outdated Show resolved Hide resolved
    * ACE/ace/Malloc_T.h:
    * ACE/ace/Malloc_T.cpp:
    * ACE/ace/Shared_Memory_Pool.cpp:
    * ACE/ace/Shared_Memory_Pool.h:
    * ACE/ace/Malloc_T.cpp:
    * ACE/ace/Malloc_T.h:
ACE/ace/Shared_Memory_Pool.cpp Outdated Show resolved Hide resolved
jwillemsen and others added 2 commits June 20, 2023 08:05
Co-authored-by: Adam Mitz <mitza@objectcomputing.com>
@jwillemsen jwillemsen merged commit 7ee0839 into master Jun 21, 2023
80 of 81 checks passed
@jwillemsen jwillemsen deleted the jwi-shmem branch June 21, 2023 06:10
mitza-oci added a commit to mitza-oci/ACE_TAO that referenced this pull request Jun 22, 2023
Fix ACE_Shared_Memory_Pool

(cherry picked from commit 7ee0839)

# Conflicts:
#	ACE/NEWS
#	ACE/ace/SV_Shared_Memory.h
#	ACE/ace/Shared_Memory_Pool.cpp
#	ACE/examples/System_V_IPC/SV_Semaphores/Semaphores_2.cpp
#	ACE/tests/SV_Shared_Memory_Test.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

ACE_Shared_Memory_Pool doesn't call shmdt
2 participants