diff --git a/Source/Core/Common/MemArena.h b/Source/Core/Common/MemArena.h index 4f414afa27..709dd6b2e4 100644 --- a/Source/Core/Common/MemArena.h +++ b/Source/Core/Common/MemArena.h @@ -124,6 +124,9 @@ private: int m_shm_fd = 0; void* m_reserved_region = nullptr; std::size_t m_reserved_region_size = 0; +#ifndef ANDROID + std::string m_seg_name; +#endif #endif }; diff --git a/Source/Core/Common/MemArenaUnix.cpp b/Source/Core/Common/MemArenaUnix.cpp index 1afa1a913f..e7b6ae9c30 100644 --- a/Source/Core/Common/MemArenaUnix.cpp +++ b/Source/Core/Common/MemArenaUnix.cpp @@ -30,8 +30,8 @@ MemArena::~MemArena() = default; void MemArena::GrabSHMSegment(size_t size, std::string_view base_name) { - const std::string file_name = fmt::format("/{}.{}", base_name, getpid()); - m_shm_fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); + m_seg_name = fmt::format("/{}.{}", base_name, getpid()); + m_shm_fd = shm_open(m_seg_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600); if (m_shm_fd == -1) { ERROR_LOG_FMT(MEMMAP, "shm_open failed: {}", strerror(errno)); @@ -43,6 +43,7 @@ void MemArena::GrabSHMSegment(size_t size, std::string_view base_name) void MemArena::ReleaseSHMSegment() { + shm_unlink(m_seg_name.c_str()); close(m_shm_fd); }