首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏码匠的流水账

    聊聊netty的maxDirectMemory

    序 本文主要研究一下netty的maxDirectMemory(io.netty.maxDirectMemory) reactive-server-with-netty-76-638.jpg PlatformDependent long maxDirectMemory = SystemPropertyUtil.getLong("io.netty.maxDirectMemory", -1); ​ if (maxDirectMemory : {} bytes", maxDirectMemory); DIRECT_MEMORY_LIMIT = maxDirectMemory >= 1 ? 到maxDirectMemory,如果maxDirectMemory值小于0,则设置maxDirectMemory为MAX_DIRECT_MEMORY;DIRECT_MEMORY_LIMIT = maxDirectMemorymaxDirectMemory,如果maxDirectMemory值小于0,则设置maxDirectMemory为MAX_DIRECT_MEMORY;DIRECT_MEMORY_LIMIT = maxDirectMemory

    1.4K20发布于 2019-04-02
  • 来自专栏码匠的流水账

    聊聊netty的maxDirectMemory

    序 本文主要研究一下netty的maxDirectMemory(io.netty.maxDirectMemory) PlatformDependent netty-common-4.1.33.Final-sources.jar long maxDirectMemory = SystemPropertyUtil.getLong("io.netty.maxDirectMemory", -1); if (maxDirectMemory : {} bytes", maxDirectMemory); DIRECT_MEMORY_LIMIT = maxDirectMemory >= 1 ? 到maxDirectMemory,如果maxDirectMemory值小于0,则设置maxDirectMemory为MAX_DIRECT_MEMORY;DIRECT_MEMORY_LIMIT = maxDirectMemorymaxDirectMemory,如果maxDirectMemory值小于0,则设置maxDirectMemory为MAX_DIRECT_MEMORY;DIRECT_MEMORY_LIMIT = maxDirectMemory

    2.2K30发布于 2019-04-25
  • 来自专栏码匠的流水账

    聊聊jvm的-XX:MaxDirectMemorySize

    . // public static long maxDirectMemory() { return directMemory; } ​ //...... -1,那么则设置为Runtime.getRuntime().maxMemory();如果有设置MaxDirectMemorySize且值大于-1,那么使用该值作为directMemory的值;而VM的maxDirectMemory 方法则返回的是directMemory的值 获取maxDirectMemory的值 实例 public BufferPoolMXBean getDirectBufferPoolMBean(){ java.base/jdk/internal/misc/VM.java中可以看到默认是取的Runtime.getRuntime().maxMemory() 使用jdk.internal.misc.VM.maxDirectMemory ()可以获取maxDirectMemory的值;由于java9模块化之后,VM从原来的sun.misc.VM变更到java.base模块下的jdk.internal.misc.VM;上面代码默认是unamed

    14K30发布于 2019-03-28
  • 来自专栏java学习java

    redis缓存问题引进

    他使用netty进行网络通信 //2)lettuce的bug导致netty堆外内存溢出 netty如果没有指定堆外内存,默认使用-Xmx //可以通过-Dio.netty.maxDirectMemory 进行设置 //解决方案:不能使用-Dio.netty.maxDirectMemory只去调大 //1)升级lettuce //2)切换使用jedis //lettuce jedis操作redis底层的客户端

    37620编辑于 2023-10-15
  • 来自专栏聊聊Netty那些事儿

    聊一聊 Netty 数据搬运工 ByteBuf 体系的设计与实现

    都是带有 Cleaner 的,这种情况下 Netty 并不会限制 maxDirectMemory 的用量,因为限制了也没用,具体能用多少 maxDirectMemory,还是由 JVM 参数 -XX: 这里需要特别注意的是,Netty 层面对于 maxDirectMemory 的容量限制和 JVM 层面对于 maxDirectMemory 的容量限制是单独分别计算的,互不影响。 io.netty.maxDirectMemory > 0 的情况和小于 0 的情况一样,唯一不同的是 Netty 层面的 maxDirectMemory 用量是专门由 -Dio.netty.maxDirectMemory (); static { long maxDirectMemory = SystemPropertyUtil.getLong("io.netty.maxDirectMemory : {} bytes", maxDirectMemory); DIRECT_MEMORY_LIMIT = maxDirectMemory >= 1 ?

    61410编辑于 2024-08-16
  • 来自专栏技术客栈

    Java直接内存分配和释放的讲解

    void reserveMemory(long size, int cap) { // 初始化maxMemory,如果没有指定-XX:MaxDirectMemorySize, // 就使用VM.maxDirectMemory MEMORY_LIMIT_SET && VM.initLevel() >= 1) { MAX_MEMORY = VM.maxDirectMemory(); MEMORY_LIMIT_SET

    1.4K40编辑于 2023-07-20
  • 来自专栏码农知识点

    Java NIO实现原理之Buffer

    memoryLimitSet && VM.isBooted()) { maxMemory = VM.maxDirectMemory(); memoryLimitSet 代码中maxMemory = VM.maxDirectMemory(); private static long directMemory = 64 * 1024 * 1024; //64MB public static long maxDirectMemory() { return directMemory; } 实际上在 JVM启动时,会对System做初始化,实际上堆外内存的大小设置逻辑为

    70010发布于 2020-06-19
  • 来自专栏Java3y

    常见的 OOM 异常分析(硬核干货)

    DirectBufferMemoryDemo { public static void main(String[] args) { System.out.println("maxDirectMemory is:"+sun.misc.VM.maxDirectMemory() / 1024 / 1024 + "MB"); //ByteBuffer buffer = ByteBuffer.allocate maxDirectMemory is:5MB Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory 4.2

    2.2K11发布于 2020-07-09
  • 来自专栏老付的网络博客

    简述 G1 垃圾回收器和 OOM 问题的排查

    System.out.println(Runtime.getRuntime().maxMemory() / 1024.0 / 1024.0); System.out.println(VM.maxDirectMemory

    3.1K30发布于 2021-01-28
  • 来自专栏JavaKeeper

    10种常见OOM分析——手把手教你写bug

    DirectBufferMemoryDemo { public static void main(String[] args) { System.out.println("maxDirectMemory is:"+sun.misc.VM.maxDirectMemory() / 1024 / 1024 + "MB"); //ByteBuffer buffer = ByteBuffer.allocate maxDirectMemory is:5MB Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory 4.2

    1.2K41发布于 2020-07-21
  • 来自专栏只为你下

    数据湖应用解析:Spark on Elasticsearch一致性问题

    DirectBufferMemoryDemo { public static void main(String[] args) www.javachenglei.com { System.out.println("maxDirectMemory is:"+sun.misc.VM.maxDirectMemory() / 1024 / 1024 + "MB"); //ByteBuffer buffer = ByteBuffer.allocate maxDirectMemory is:5MB Exception in thread www.xingyunylpt.com"main" java.lang.OutOfMemoryError: Direct

    1.2K20发布于 2020-07-21
  • 来自专栏java开发的那点事

    19-Log4j整合到Netty

    sun.arch.data.model) [DEBUG]Slf4JLogger--Dio.netty.noPreferDirect: false [DEBUG]Slf4JLogger--Dio.netty.maxDirectMemory

    43510编辑于 2022-02-18
  • 来自专栏大数据成神之路

    Flink1.14.2发布,除了log4j漏洞你还需要关注什么?

    在Java 11 上,它将从 Java 直接内存池中分配内存,并受 MaxDirectMemory限制。当前的Pulsar客户端没有用于控制内存限制的配置选项,这可能导致OOM。

    1.3K10编辑于 2022-01-20
  • 来自专栏第三方工具

    OOM异常的4种可能分析及常见的OOM异常演示

    * 报错:java.lang.OutOfMemoryError: Direct buffer memory */ // System.out.println("配置的maxDirectMemory : " + (sun.misc.VM.maxDirectMemory() / (double) 1024 / 1024) + "MB"); // //最大5M 申请6M //

    86510编辑于 2024-10-09
  • 来自专栏公众号-测试驿栈

    JVM 内存区域大小参数设置

    该值是有上限的,默认是64M,最大为sun.misc.VM.maxDirectMemory()。   

    9.8K21发布于 2019-09-26
  • 来自专栏编码前线

    JAVA面试50讲之10:直接(堆外)内存原理及使用

    memoryLimitSet && VM.isBooted()) { maxMemory = VM.maxDirectMemory(); memoryLimitSet DirectByteBuffer通过sun.misc.VM#maxDirectMemory来获取这个值,可以看一下对应的代码: // A user-settable upper limit on the //public static long maxDirectMemory() { return directMemory;} 这里directMemory默认赋值为64MB,那对外内存的默认大小是

    3.2K51发布于 2019-01-23
  • 来自专栏java 成神之路

    JVM 内存区域大小参数设置

    注意该值是有上限的,默认是64M,最大为sun.misc.VM.maxDirectMemory(),在程序中中可以获得-XX:MaxDirectMemorySize的设置的值。

    5.6K150发布于 2018-05-18
  • 来自专栏JAVA

    JVM面试题解析

    =5m public class DirectBufferDemo { public static void main(String[] args) { System.out.println("maxDirectMemory : " + sun.misc.VM.maxDirectMemory() / (1024 * 1024) + "MB"); ByteBuffer byteBuffer = ByteBuffer.allocateDirect (6 * 1024 * 1024); } }Copy to clipboardErrorCopied 输出 maxDirectMemory : 5MB [GC (System.gc()) [PSYoungGen

    19000编辑于 2024-11-20
  • 来自专栏JavaEdge

    DirectByteBuffer内存释放

    memoryLimitSet && VM.isBooted()) { maxMemory = VM.maxDirectMemory(); memoryLimitSet

    4.3K50编辑于 2021-12-07
  • 来自专栏瓜农老梁

    Netty10# 堆外内存底盘PlatformDependent

    UNSAFE_UNAVAILABILITY_CAUSE中 DIRECT_BUFFER_PREFERRED 默认优先使用堆外内存分配 MAX_DIRECT_MEMORY 获取最大堆外内存通过sun.misc.VM#maxDirectMemory

    93010发布于 2021-02-24
领券