webClient 出现io.netty.util.internal.OutOfDirectMemoryError

问题描述:
使用webClient调用第三方接口进行文件上传操作,在并发量升高的情况下,出现异常:

io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 16777216 byte(s) of direct memory (used: 2130706439, max: 2147483648)
        at io.netty.util.internal.PlatformDependent.incrementMemoryCounter(PlatformDependent.java:742) 
        at io.netty.util.internal.PlatformDependent.allocateDirectNoCleaner(PlatformDependent.java:697) 
        at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:758) 
        at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:734) 
        at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:245) 
        at io.netty.buffer.PoolArena.allocate(PoolArena.java:215) 
        at io.netty.buffer.PoolArena.allocate(PoolArena.java:147) 
        at io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:356) 
        at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187) 
        at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:178) 
        at io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:139) 
        at io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:114) 
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:147) 
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) 
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) 
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) 
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) 
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) 
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) 
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) 
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]

系统情况:

springboot 2.3.6
spring-webflux:2.3.6
jdk 1.8
MaxDirectMemorySize=512M

产生异常的代码片段:

Mono<String> mono= WebClient.create().post().uri(url).header(HttpHeaders.AUTHORIZATION, getAuthToken())
					.contentType(MediaType.APPLICATION_JSON).body(BodyInserters.fromObject(fileObject)).retrieve()
					.bodyToMono(String.class);
String responseString = mono.block();

请教各位大佬,有遇到这种问题吗?怎么解决的呢?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值