![龙之队|一次线上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
推荐阅读
-
@梦幻西游:玩梦幻遇到不懂就要问,不然任务都不敢做
-
商户之家网页版—2022年工银商户之家手续费怎么收的?
-
健身者教练|速来了解如何正确地深蹲,你会进行深蹲吗?90%的人都蹲错了
-
冬天嘴唇老是脱皮是什么原因 冬天嘴唇容易脱皮正确的应对方法是
-
#峰哥全村第一帅#虞书欣组获得倒数第一时,有谁注意她说了啥?心态可真好,原创
-
-
-
[小鱼儿笑看娱乐]邓婕前夫曝光,网友:张国立和他根本不是一个档次,隐瞒了30多年
-
-
鸡汤喝到吐|卡特再就业,新星或下赛季报销,NBA消息!利拉德詹皇收喜讯
-
-
高中生跳河救轻生女,湿漉漉回家称掉河里被妈妈一顿骂
-
-
微笑|《2012》小配角「初恋感甜甜微笑」爆红,长大变甜酷辣妹反差超强
-
何洁|何洁突晒27支蜡烛表情,疑为家乡遇难者致哀,留言区评价不一
-
-
【AQ谈游戏】王者荣耀:为何代练技能打人那么准?代练:学会后别乱说
-
-
-
台式燃气灶风门调节方法视频 台式燃气灶风门调节方法