Memory leak on GregorianCalendar

We are having this error and the JSP page becomes blank (white):

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,H OUR_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.

Suggested solutions are:

  • use new instances for each time a Calendar is needed or

  • check whether some hook in ResultSet.close is sufficient for calling ThreadLocal.remove()

  • However, in our case we need to reproduce the error, so it is possible to test the fix, without waiting indefinitely for the error to happen again.


    The given message is not the cause of your problem.

    Tomcat is only informing that there could be a memory leak (which must not be true). This error occurs during shutdown every time (try it).


    In addition to answer given by @Uwe Plonus I can say that this happens when application is stopped. So, unless you stop and start your application multiple times without restarting your tomcat this is not so interesting. If this happens when tomcat is closing applications during its shutdown this memory leak is irrelevant: the tomcat itself will die in a moment.

    链接地址: http://www.djcxy.com/p/3102.html

    上一篇: f:如果时区由bean提供,则convertDateTime显示错误日期

    下一篇: GregorianCalendar上的内存泄漏