@Override
    public void updateHealthStatus() {
        // No need to call "UnpooledByteBufAllocator.DEFAULT.metric().usedDirectMemory()"
        // and "PooledByteBufAllocator.DEFAULT.metric().usedDirectMemory()"
        // because we have requested Netty to create DirectBuffer instances via its constructor with
        // the counter supported by JDK
        long localUsedDirectMemory = directBufferPoolBean.getMemoryUsed();
        usedDirectMemory = localUsedDirectMemory;
        long localUsedHeapMemory = memoryMXBean.getHeapMemoryUsage()
                .getUsed();
        usedHeapMemory = localUsedHeapMemory;
        // Non-heap memory pools: [CodeHeap 'non-nmethods', CodeHeap 'non-profiled nmethods',
        // CodeHeap 'profiled nmethods',
        // Compressed Class Space, Metaspace]
        // via ManagementFactory.getMemoryPoolMXBeans().stream().filter(bean -> bean.getType() ==
        // MemoryType.NON_HEAP)
        // .map(MemoryPoolMXBean::getName).sorted().toList().toString()
        long localUsedNonHeapMemory = memoryMXBean.getNonHeapMemoryUsage()
                .getUsed();
        usedNonHeapMemory = localUsedNonHeapMemory;
        long localUsedAvailableMemory =
                localUsedDirectMemory + localUsedHeapMemory + localUsedNonHeapMemory;
        usedAvailableMemory = localUsedAvailableMemory;
        long localFreeSystemMemory = operatingSystemBean.getFreeMemorySize();
        long localUsedSystemMemory = totalPhysicalMemorySize - localFreeSystemMemory;
        usedSystemMemory = localUsedSystemMemory;

        boolean localIsMemoryHealthy;
        if (localUsedAvailableMemory < maxAvailableMemory
                && localUsedDirectMemory < maxAvailableDirectMemory
                && localFreeSystemMemory > minFreeSystemMemory) {
            unhealthyReason = null;
            localIsMemoryHealthy = true;
        } else {
            unhealthyReason =
                    "The memory is insufficient. The insufficient memory usage snapshot is: "
                            + "Used system memory: "
                            + asMbString(localUsedSystemMemory)
                            + "/"
                            + asMbString(totalPhysicalMemorySize)
                            + "; "
                            + "Used available memory: "
                            + asMbString(localUsedAvailableMemory)
                            + "/"
                            + asMbString(maxAvailableMemory)
                            + "; "
                            + "Used direct memory: "
                            + asMbString(localUsedDirectMemory)
                            + "/"
                            + asMbString(maxAvailableDirectMemory);
            localIsMemoryHealthy = false;
        }
        isMemoryHealthy = localIsMemoryHealthy;
        tryLog(localIsMemoryHealthy);
    }
@author James Chen
@implNote JVM Total Memory: 1. Off-Heap: a. Mapped files, b. Direct buffers c. Java stacks d.
          Metaspace (Class metadata: Constant pool, Field & Method data), e. Native code (JVM
          internal use only): PC registers, Native method stacks, Code cache, Structures used &
          allocated by native libraries(e.g IO libraries), Shared libraries of the JVM, etc. f.
          etc 2. Heap (eden, survivor, old)
          <a href="https://www.oracle.com/technetwork/tutorials/tutorials-1876574.html"> Getting
          Started with the G1 Garbage Collector</a>
@see jdk.internal.access.JavaNioAccess#getDirectBufferPool
@see io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics
turms-server-common/src/main/java/im/turms/server/common/infra/healthcheck/MemoryHealthChecker.java