gpt4 book ai didi

java - Tomcat session 未正确清理

转载 作者:行者123 更新时间:2023-11-28 22:27:37 29 4
gpt4 key购买 nike

我们遇到了内存泄漏。只要未正确清理 tomcat session ,就会发生这种情况。我们创建的堆转储之一显示 session 中有 2.5GB。日志显示以下内容:

2016-03-10 19:32:34,976 INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - D50C0D6ADC7A02B71032E729692D3341.tomcat02 IS REMOVED(sessions.size=101)
2016-03-10 19:32:34,977 INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - F552AF04CCA3E5987CA12B3CA707A65B.tomcat02 IS REMOVED(sessions.size=100)
2016-03-10 19:33:35,456 INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 9B20DEFCC6AA4B4E83E59D1C9E017EC2.tomcat02 IS REMOVED(sessions.size=99)
2016-03-10 19:33:35,456 INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - A56C5E65C5F4230A3699E5B46BEAA5A7.tomcat02 IS REMOVED(sessions.size=98)
2016-03-10 19:33:35,554 INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - F7419BD927689F359C4FD9E382CECB35.tomcat02 IS REMOVED(sessions.size=97)
2016-03-10 19:33:35,608 INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 86A2EC35561C2A6F6CC33E9279D8D378.tomcat02 IS REMOVED(sessions.size=96)
2016-03-10 19:33:35,608 INFO ContainerBackgroundProcessor[StandardEngine[Catalina]] de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - AFEC9F52D6552569B0D6E3010D0025F7.tomcat02 IS REMOVED(sessions.size=95)
2016-03-10 19:47:39,831 INFO ajp-bio-8010-exec-4652 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 8177FD469930CC8C58A40E1AC05DDF3D.tomcat02 IS REMOVED(sessions.size=121)
2016-03-10 19:47:51,802 INFO ajp-bio-8010-exec-4671 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - C70F96B181343936D9B763AA8E058462.tomcat02 IS REMOVED(sessions.size=123)
2016-03-10 19:47:52,008 INFO ajp-bio-8010-exec-4672 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - AB5A52D70167AB73B50BC15F38CCC555.tomcat02 IS REMOVED(sessions.size=124)
2016-03-10 19:48:19,638 INFO ajp-bio-8010-exec-4688 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - C1171F663AF81155B033090F6A6526F4.tomcat02 IS REMOVED(sessions.size=124)
2016-03-10 19:50:50,764 INFO ajp-bio-8010-exec-4377 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - A78314AFA1A0864F61FBBC8A3F87DDFC.tomcat02 IS REMOVED(sessions.size=132)
2016-03-10 19:51:12,568 INFO ajp-bio-8010-exec-4555 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 34ADDDB2CFF705946160B32B0C3A07E8.tomcat02 IS REMOVED(sessions.size=134)
2016-03-10 19:51:15,115 INFO ajp-bio-8010-exec-4533 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 1697EFBFEE37928D77CB82C403FAAB81.tomcat02 IS REMOVED(sessions.size=134)
2016-03-10 19:51:45,837 INFO ajp-bio-8010-exec-4602 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - BCD0654B34CBEE18AEF8FF72BF13517A.tomcat02 IS REMOVED(sessions.size=139)
2016-03-10 19:53:14,098 INFO ajp-bio-8010-exec-4603 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 62FCB3CBF8F923F0005BD77CB1658B98.tomcat02 IS REMOVED(sessions.size=159)
2016-03-10 19:58:36,482 INFO ajp-bio-8010-exec-4574 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 8CD74088FAB550870ECB6242B1A0DEEC.tomcat02 IS REMOVED(sessions.size=194)
2016-03-10 19:58:54,167 INFO ajp-bio-8010-exec-4601 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - FC91875E280724BD1397D4BC7ED80CF8.tomcat02 IS REMOVED(sessions.size=196)
2016-03-10 19:59:04,894 INFO ajp-bio-8010-exec-4709 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - BEF4DF2EDC5217370679B6C9F06D8BA3.tomcat02 IS REMOVED(sessions.size=197)
2016-03-10 19:59:35,716 INFO ajp-bio-8010-exec-4723 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 0B5CB30250F81D0AFFAA479E13501DD4.tomcat02 IS REMOVED(sessions.size=205)

... 一段时间后,我们面临着仅属于 50 个用户的大约 2k session 。

2016-03-10 23:59:36,641 INFO ajp-bio-8010-exec-5973 de.projekt.application.SessionListener.sessionDestroyed(150) - SESSION_DESTROYED - 1B086A93D55A748D3E8769A957A06FD0.tomcat02 IS REMOVED(sessions.size=1518)

这些 session 的清理一直在进行,直到 ContainerBackgroundProcessor[StandardEngine[Catalina]] 线程调用 SessionListener。突然间,该线程不再调用 SessionListener。相反,它由 ajp-bio 线程调用,并且 session 数量正在增加。

有人可以向我解释为什么 ajp-bio 线程突然调用 SessionListener 而不是 ContainerBackgroundProcessor[StandardEngine[Catalina]] 线程吗?

此时 Catalina 没有异常(exception)。 tomcat也有足够的内存。

--编辑--

网络.xml

<session-config>
<session-timeout>30</session-timeout>
<tracking-mode>COOKIE</tracking-mode>
</session-config>

最佳答案

您应该配置 web.xml 以便 session 在指定时间后自动过期。在那种情况下,将不会有孤立 session

关于java - Tomcat session 未正确清理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35942587/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com