gpt4 book ai didi

java - GregorianCalendar 上的内存泄漏

转载 作者:行者123 更新时间:2023-11-28 23:03:37 25 4
gpt4 key购买 nike

出现此错误,JSP 页面变为空白(白色):

Jan 9, 2013 7:30:39 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap SEVERE: The web application [/MyWebApp] created a ThreadLocal with key of type [net.sourceforge.jtds.jdbc.DateTime$1] (value [net.sourceforge.jtds.jdbc.DateTime$1@48a47]) and a value of type [java.util.GregorianCalendar] (value [java.util.GregorianCalendar[time=1357531128420,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Australia/Sydney",offset=36000000,dstSavings=3600000,useDaylight=true,transitions=142,lastRule=java.util.SimpleTimeZone[id=Australia/Sydney,offset=36000000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=1,endMode=3,endMonth=3,endDay=1,endDayOfWeek=1,endTime=7200000,endTimeMode=1]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2013,MONTH=0,WEEK_OF_YEAR=2,WEEK_OF_MONTH=2,DAY_OF_MONTH=7,DAY_OF_YEAR=7,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=2,HOUR_OF_DAY=14,MINUTE=58,SECOND=48,MILLISECOND=420,ZONE_OFFSET=36000000,DST_OFFSET=3600000]]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

建议的解决方案是:

  • 每次需要Calendar 时使用新的实例

  • 检查 ResultSet.close 中的某些钩子(Hook)是否足以调用 ThreadLocal.remove()

但是,在我们的例子中,我们需要重现错误,因此可以测试修复,而不必无限期地等待错误再次发生。

最佳答案

给定的消息不是问题的原因。

Tomcat 仅通知​​可能存在内存泄漏(这一定不是真的)。每次关机都会出现这个错误(试试看)。

关于java - GregorianCalendar 上的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14235228/

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