小编Ale*_*lex的帖子

使用netty高速发送邮件时获取OOM异常

我用netty编写了一个客户端,以便以高速率发送消息.通过jConsole我看到"old gen"正在增加,最后它抛出了java.lang.OutOfMemoryError:超出了GC开销限制.是否有一些方法或配置来避免此异常以下是我的测试代码:

    import io.netty.bootstrap.Bootstrap;
    import io.netty.channel.Channel;
    import io.netty.channel.ChannelFuture;
    import io.netty.channel.ChannelInitializer;
    import io.netty.channel.ChannelOption;
    import io.netty.channel.ChannelPipeline;
    import io.netty.channel.EventLoopGroup;
    import io.netty.channel.nio.NioEventLoopGroup;
    import io.netty.channel.socket.SocketChannel;
    import io.netty.channel.socket.nio.NioSocketChannel;
    import io.netty.handler.codec.string.StringEncoder;

    import java.io.IOException;
    import java.net.UnknownHostException;
    import java.util.concurrent.ExecutionException;
    import java.util.concurrent.TimeoutException;

    public class TestNettyTcp {
        private EventLoopGroup group;

        private Channel ch;

        /**
         * @param args
         * @throws SyslogSenderException
         * @throws TimeoutException
         * @throws ExecutionException
         * @throws IOException
         * @throws InterruptedException
         * @throws UnknownHostException
         */
        public static void main( String[] args )
            throws UnknownHostException, InterruptedException, IOException,  ExecutionException,  TimeoutException {
            new …
Run Code Online (Sandbox Code Playgroud)

java out-of-memory netty

3
推荐指数
1
解决办法
2786
查看次数

标签 统计

java ×1

netty ×1

out-of-memory ×1