From cf12a2fae11baf41773308a48d9cfad9031f5344 Mon Sep 17 00:00:00 2001
Date: Fri, 9 Sep 2022 11:26:22 +0800
Subject: dynamic cds _header and _fd handles are not free.

---
 hotspot/src/share/vm/memory/filemap.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp
index adb043f77..6549828e3 100644
--- a/hotspot/src/share/vm/memory/filemap.cpp
+++ b/hotspot/src/share/vm/memory/filemap.cpp
@@ -169,6 +169,18 @@ FileMapInfo::~FileMapInfo() {
     assert(_dynamic_archive_info == this, "must be singleton"); // not thread safe
     _dynamic_archive_info = NULL;
   }
+
+  if (_header != NULL) {
+    delete _header;
+  }
+
+  if (_file_open) {
+    if (::close(_fd) < 0) {
+      fail_stop("Unable to close the shared archive file.");
+    }
+    _file_open = false;
+    _fd = -1;
+  }
 }
 
 void FileMapInfo::populate_header(size_t alignment) {
-- 
2.22.0

