![龙之队|一次线上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
推荐阅读
-
-
-
旧史心说“郭嘉不死,卧龙不出”,却往往遗忘后面那句经典,世人皆知
-
墨西哥总统致信教皇要求道歉,因为500年前的这件事.
-
菲龙网|菲律宾卫生部尚无法确定激增病例是否有放宽隔离限制有关
-
Angelababy|Angelababy懒甩“黄晓明同框新欢”现身百花奖,徐娇穿马面裙登红毯
-
-
-
懒猫深聊娱乐|就引导粉丝问题,肖战工作室公开道歉!,微博约谈肖战工作室
-
记得看一位知友回答问题时放了一张民国时期穿旗袍坐着的复古系写真,漂亮极了,当时看过忘了问哪里拍的了
-
-
中国网价值风暴席卷中原 欧航欧马可超级卡车劲“爽”科技&环保之美
-
-
标致308|看中标致308,长期开,不说保值率,有客观点的评价吗?
-
-
身体|【你馋吗】Baby晒体重不足90斤,身体年龄仅26岁
-
那个女孩不一般|孩子一定避而远之,会损害孩子的健康,家长要警惕!,这4种水果
-
勇士队|灰暗之日!克莱赛季报销,勇士大交易迎汤神替身,火箭被取笑
-
「筝弦上的赵姐」坐公交车的时候不小心洒了,开心笑话:买了一盒臭豆腐
-
恩平微讯@民警及时救助脱险!,恩平一女子不慎跌落河道