![龙之队|一次线上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
推荐阅读
-
育儿小手册:谁能无伤打主宰?李白认怂,百里玄策自闭,他:0难度,若删除吸血装备
-
【中华网财经】最高处罚!蒋凡遭除名阿里合伙人 揭秘阿里合伙人制度
-
新华网|今年入汛以来最大洪水抵达三峡 流量超6万立方米/秒
-
#幸福的新生活#开花妖艳,造型秀丽,泡茶喝还营养,天热也能养菊花?这几款菊花
-
Boos游戏解说|道歉后第9天,刘思瑶“恰饭”视频引争议,而黑粉的话令人气愤!
-
美国@美国“末日”真正降临!白宫即将沦陷,特朗普连夜逃离美国?
-
-
-
梁山|梁山八骠骑没有豹子头林冲,也没有大刀关胜,却有他!
-
『印度』传来噩耗!截至5月8日15时,俄罗斯印度开启“王炸”模式!
-
-
娟娟聊娱乐:释放一危险信号。,亚洲第二个日本诞生?此国义无反顾投入美国怀抱
-
神小扣|哪部是你的童年?,近几年很少重播的十部古装剧
-
三十而已|《三十而已》即将收官,又一都市剧接档,女主也是一位“白月光”
-
华为|不再依靠4G打电话!华为完成首个5G规模商用网络VoNR验证
-
血糖小助手|5个习惯要改掉!常做一个小动作有助脑健康,不想得老年痴呆
-
华为|华为高管秀HMS成果,引来国内众应用转发支持,附图
-
雪儿小姐的情书|大都有这些特征,有一定的道理,“骨子里”自信的女人
-
新华网|纽约商品交易所黄金期货市场12月黄金期价18日上涨
-
好六网|DNF:国服第一剑宗率先归位,20秒打出2.3万亿新纪录,但水分大