We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
因网络不通而频繁创建NioEvenLoopGroup导致内存耗尽,是我在项目中真实遇到的问题。 另外如果连接目标(包括失效的)过多也会导致内存耗尽,该问题在docker/k8s随机网络分配的环境下更明显 。 NioEvenLoopGroup应该使用单例模式,以下是我的解决方案:
定义自动检查的单例:
// 须使用getEventLoopGroup方法获取,勿直接使用 private static EventLoopGroup group = new NioEventLoopGroup(); private static ReentrantLock reentrantLock = new ReentrantLock(); public static EventLoopGroup getEventLoopGroup() { try { // 共享NioEventLoopGroup,因为是频繁要用的所以不要关闭group if (reentrantLock.tryLock(5, TimeUnit.SECONDS)) { // 如果关闭了则重新创建NioEventLoopGroup if (group == null || group.isShutdown() || group.isShuttingDown()) { group = new NioEventLoopGroup(); } return group; } else { throw new IllegalStateException("Get the EventLoopGroup fail"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Get the EventLoopGroup fail"); } finally { reentrantLock.unlock(); } }
使用时调用 getEventLoopGroup() 方法。
The text was updated successfully, but these errors were encountered:
你好,问题已修复并推送master分支,可以pull master体验下。将会跟随下个版本发布。
Sorry, something went wrong.
No branches or pull requests
因网络不通而频繁创建NioEvenLoopGroup导致内存耗尽,是我在项目中真实遇到的问题。
另外如果连接目标(包括失效的)过多也会导致内存耗尽,该问题在docker/k8s随机网络分配的环境下更明显 。
NioEvenLoopGroup应该使用单例模式,以下是我的解决方案:
定义自动检查的单例:
使用时调用 getEventLoopGroup() 方法。
The text was updated successfully, but these errors were encountered: