![龙之队|一次线上JVM内存溢出分析,GC分析、MAT、gcviewer]()
终于找到了与tomcat相关的类了 , 开心!!!!!
?public class Nio2Endpoint extends AbstractJsseEndpoint {...@Overridepublic void bind() throws Exception {?// Create worker collectionif (getExecutor() == null) {createExecutor();// 统一在这个方法创建线程池}if (getExecutor() instanceof ExecutorService) {threadGroup = AsynchronousChannelGroup.withThreadPool((ExecutorService) getExecutor());}// AsynchronousChannelGroup needs exclusive access to its executor serviceif (!internalExecutor) {log.warn(sm.getString("endpoint.nio2.exclusiveExecutor"));}?serverSock = AsynchronousServerSocketChannel.open(threadGroup);socketProperties.setProperties(serverSock);InetSocketAddress addr = new InetSocketAddress(getAddress(), getPortWithOffset());serverSock.bind(addr, getAcceptCount());?// Initialize SSL if neededinitialiseSsl();}...@Overridepublic void startInternal() throws Exception {?if (!running) {allClosed = false;running = true;paused = false;?if (socketProperties.getProcessorCache() != 0) {processorCache = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE,socketProperties.getProcessorCache());}if (socketProperties.getBufferPool() != 0) {nioChannels = new SynchronizedStack<>(SynchronizedStack.DEFAULT_SIZE,socketProperties.getBufferPool());}?// Create worker collectionif (getExecutor() == null) {createExecutor();// 统一在这个方法创建线程池}?initializeConnectionLatch();startAcceptorThread();}}...}/** * AprEndpoint使用JNI的接口来获得对Socket的访问 * NioEndpoint 同步 * Nio2Endpoint 异步 */// 调用 NioEndpoint、Nio2Endpoint、AprEndpoint的父类AbstractEndpoint#createExecutor()方法public abstract class AbstractEndpoint {...// 创建线程池public void createExecutor() {internalExecutor = true;TaskQueue taskqueue = new TaskQueue();// 找到了我们的类 TaskThreadFactoryTaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS,taskqueue, tf);taskqueue.setParent( (ThreadPoolExecutor) executor);}...}?【龙之队|一次线上JVM内存溢出分析,GC分析、MAT、gcviewer】上面涉及到Tomcat的网络NIO架构 , 大家更感兴趣的可以百度搜索相关文章 。 Nio2Endpoint的作用大致就是为Http请求分配线程执行 , 到这里大概明白byte[]数组就是分配在每一个tomact线程中 , 因为使用了Nio , 就会有Buffer概念 , 那么这部分的内存是不能回收的 , 系统启动之后就一直不变 。 而且随着配置的tomcat线程server.tomcat.maxThreads越多占用的内存空间就越大 。
随着配置的tomcat线程越多占用的内存空间就越大?
这个时候我联想到了配置文件 , 查看原来配置文件:application.yml
server:port: 80tomcat:uri-encoding: UTF-8maxHttpPostSize: 10240000maxHttpHeaderSize: 10240000maxThreads: 500acceptCount: 500maxConnections: 600minSpareThreads: 100
推荐阅读
-
小S|金钟奖:小S披“战服”零奖项输给前任,黄子佼五五分土味十足
-
00后|00后男子罕见钓获6斤的大鳜鱼,骑车绕村显摆,网友:成臭鳜鱼了
-
吃货老崔|缘分已到,难逃桃花劫的四星座,再续前缘,相伴一生!,未来一周
-
-
汽车车集结号|1.4T+爱信6AT,6万开出20万档次,这才是年轻人座驾!比思域漂亮
-
时尚颠峰|既复古又潮流,如何穿得更像法国风格的服装搭配
-
易车|给家用加点猛料,实拍第二代捷途X70,四出排气+连屏
-
人民日报|国家防总维持长江淮河防汛Ⅱ级响应 中央防汛救灾物资继续向湘赣皖调拨
-
-
-
晚餐|我家的晚餐,发到朋友圈后沸腾了,亲友:吃得够营养,有钱真好
-
『人数』综合消息:欧洲防疫形势依然严峻 疫情缓和带来一线曙光
-
『证券市场红周刊』中手游投资云游戏技术领先服务商蔚领时代《仙剑奇侠传七》将上云
-
-
-
明明美食分享|美食推荐:柠檬蒸鱼柳、韭菜炒肉丝、毛豆烩豆腐、剁椒菜花粉丝煲
-
张云雷|他不搭?张云雷新代言遭到质疑,关于代言这影帝的话令人肃然起敬
-
大众网但大家训练热情都非常高涨,阿奇姆彭:不知道开赛准确日期
-
减肥|外行减体重,内行减体脂!怎么才能减掉脂肪,慢慢瘦下来?
-
中海|中海2020中期业绩披露:销售额1720 亿,净利润率 23.2%