@@ -0,0 +1,1275 @@
+package com.yuzhouwan.hacker.jvm.heap;%0A%0Aimport io.netty.buffer.ByteBuf;%0Aimport io.netty.buffer.Unpooled;%0Aimport io.netty.util.internal.PlatformDependent;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.util.concurrent.atomic.AtomicLong;%0A%0A/**%0A * Copyright @ 2020 yuzhouwan.com%0A * All right reserved.%0A * Function%EF%BC%9ADirectMemory Example%0A *%0A * @author Benedict Jin%0A * @see %3Ca href=%22https://yuzhouwan.com/posts/200316/%22%3ENetty%EF%BC%9A%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E5%AE%9E%E8%B7%B5%3C/a%3E%0A * @since 2020/5/20%0A */%0Apublic class DirectMemoryExample %7B%0A%0A    public static void main(String%5B%5D args) throws NoSuchFieldException, IllegalAccessException %7B%0A        final Field f = PlatformDependent.class.getDeclaredField(%22DIRECT_MEMORY_COUNTER%22);%0A        f.setAccessible(true);%0A        AtomicLong directMemory = (AtomicLong) f.get(PlatformDependent.class);%0A        System.out.println(%221) DIRECT_MEMORY_COUNTER: %22 + directMemory);%0A        ByteBuf buffer = null;%0A        try %7B%0A            buffer = Unpooled.directBuffer();%0A            buffer.writeBytes(%22yuzhouwan.com%22.getBytes());%0A            directMemory = (AtomicLong) f.get(PlatformDependent.class);%0A            System.out.println(%222) DIRECT_MEMORY_COUNTER: %22 + directMemory);%0A        %7D finally %7B%0A            if (buffer != null) %7B%0A                buffer.clear();%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add a example for direct memory