![龙之队|一次线上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
推荐阅读
-
简单观察|什么是山东浓香花生油、山东高油酸花生油?听听专家怎么说
-
彩礼|有200多万粉的旅行博主徐云吐槽说:辛苦一年多,就赚个彩礼钱
-
使徒|DNF:5合1天下无敌?5大使徒终于合体,实战效果却令人遗憾
-
-
独角鲸工作坊|官员称疫情已控制,当地居民用茶治病,巴西新冠确诊人数接近百万
-
小男孩|家中失火10岁儿子“教科书式自救”!父母却在...
-
【时尚点游戏|完全遗传妈妈基因,“最美星二代”晒照!邱淑贞女儿沈月美得惊艳】
-
-
央视新闻客户端|架上葡萄、架下茶叶 广西三江归东村走上致富路
-
-
健康成长孩子|能让你获得幸福的婚姻,婚姻是一场修行:或许这3个建议
-
-
Seven聊时尚|蔡依林带火了一种旗袍,叫上面“阔太”下面“少女”,优雅又气质
-
「新三板」7年来最重磅改革启动,新三板的“春天”来了?
-
-
李隆基其实不爱杨贵妃 唐玄宗为什么不立杨贵妃为皇后
-
-
-
[技时]起售价3999元,小米10系列迎来强敌!一加8系列发布
-
小孩不听话打了脸会有什么影响吗 孩子不听话打脸会打坏吗