spring任务:注释驱动使年轻的gc频繁

时间:2016-04-07 10:15:41

标签: java spring scheduled-tasks

我写了一份工作来记录使用@ Scheduled的内容,所以我在applicationContext.xml中添加了task:annotation-driven。

ActivityCacheJob.java:

@Component
public class ActivityCacheJob {
@Scheduled(cron = "0 * * * * ?")
  public void getActivityCacheStatus() {
    //dosomething
  }
}

的applicationContext.xml:

<task:annotation-driven />

部署后,我发现年轻的gc时间从每分钟3到15上升。

然后,我删除了job但仍然在applicationContext.xml中添加了task:annotation-driven。这个问题仍然存在。

ActivityCacheJob.java:

//@Component
public class ActivityCacheJob {
//@Scheduled(cron = "0 * * * * ?")
  public void getActivityCacheStatus() {
    //dosomething
  }
}

的applicationContext.xml:

<task:annotation-driven />

所以,我删除任务:注释驱动,使用xml,这个问题不会退出。

的applicationContext.xml:

<task:scheduled-tasks>
    <task:scheduled ref="activityCacheJob" method="getActivityCacheStatus" cron="0 * * * * ?"/>
</task:scheduled-tasks>

spring version:3.1.1.RELEASE

我的问题是为什么任务:注释驱动让年轻的gc升起?

1 个答案:

答案 0 :(得分:0)

我将spring版本从3.1.1.RELEASE更新为3.2.2.RELEASE。 这个问题已解决。