iohao / ioGame

无锁异步化、事件驱动架构设计的 java netty 网络编程框架; 轻量级,无需依赖任何第三方中间件或数据库就能支持集群、分布式; 适用于网络游戏服务器、物联网、内部系统及各种需要长连接的场景; 通过 ioGame 你可以很容易的搭建出一个集群无中心节点、集群自动化、分布式的网络服务器;FXGL、Unity、UE、Cocos Creator、Godot、Netty、Protobuf、webSocket、tcp、socket;java Netty 游戏服务器框架; Java Netty Game Server.
http://game.iohao.com
GNU Affero General Public License v3.0
918 stars 205 forks source link

随着通讯时间的增加,导致linux服务器系统的线程数用完。 #320

Closed xlgb2012 closed 5 months ago

xlgb2012 commented 5 months ago

你的问题

线程数量一直累增 java unable to create native thread: possibly out of memory or process/resource limits reached aHNK8Nkn1u

问题代码

所在类: class ExecutorRegionKit 方法: @Setter Supplier executorRegionSupplier = () -> new ExecutorRegion() { @Override public ThreadExecutorRegion getUserThreadExecutorRegion() { return new UserThreadExecutorRegion(); }

    @Override
    public ThreadExecutorRegion getSimpleThreadExecutorRegion() {
        return new SimpleThreadExecutorRegion();
    }
};

每次调用get方法,都会新生成一个ThreadExecutorRegion,然后在里面线程池数组里面选一个处理消息。 初步修改方法。暂时用这种方式处理,但是线程池数组的都是fix=1的,4核的是16个线程池,不知道会不会产生瓶颈。

UserThreadExecutorRegion userThreadExecutorRegion = new UserThreadExecutorRegion();;
SimpleThreadExecutorRegion simpleThreadExecutorRegion= new SimpleThreadExecutorRegion();;
@Setter
Supplier<ExecutorRegion> executorRegionSupplier = () -> new ExecutorRegion() {
    @Override
    public ThreadExecutorRegion getUserThreadExecutorRegion() {
        return userThreadExecutorRegion;//是单例吗?每次都创建?修改bug
    }

    @Override
    public ThreadExecutorRegion getSimpleThreadExecutorRegion() {
        return simpleThreadExecutorRegion;//是单例吗?每次都创建?
    }
};

版本

iohao commented 5 months ago

升级新版本,此问题已在 https://github.com/iohao/ioGame/releases/tag/21.4 中解决

https://github.com/iohao/ioGame/blob/7f227184c51ffc39f34d5952b5cf2775fbd42ba8/common/common-micro-kit/src/main/java/com/iohao/game/common/kit/concurrent/executor/ExecutorRegionKit.java#L40-L57

xlgb2012 commented 5 months ago

:)