ChaosYjh opened a new issue #1642: A problem about org.apache.rocketmq.common.stats.CallSnapshot URL: https://github.com/apache/rocketmq/issues/1642 After upgrading rocketmq to 4.5.1 in production, I found that the old gen continued to grow.And I used _jmap -histo_ to make two statistics every 8 days.I found that the instance of org.apache.rocketmq.common.stats.CallSnapshot takes up a lot of jvm memory space and keeps growing.Here are the statistics of two statistics: day1: <img width="945" alt="image" src="https://user-images.githubusercontent.com/27771595/70596246-5fcca600-1c20-11ea-9795-ee049b8db655.png"> day2(after 8 days): <img width="928" alt="image" src="https://user-images.githubusercontent.com/27771595/70596303-84288280-1c20-11ea-90f3-7fbdf0a03547.png"> Then I found that a new class is created each time the background statistics thread calls the sampling method in _org.apache.rocketmq.common.stats.StatsItem_.And remove when csList's size exceeds a threshold. ``` public void samplingInSeconds() { synchronized (this.csListMinute) { this.csListMinute.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value .get())); if (this.csListMinute.size() > 7) { this.csListMinute.removeFirst(); } } } public void samplingInMinutes() { synchronized (this.csListHour) { this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value .get())); if (this.csListHour.size() > 7) { this.csListHour.removeFirst(); } } } public void samplingInHour() { synchronized (this.csListDay) { this.csListDay.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value .get())); if (this.csListDay.size() > 25) { this.csListDay.removeFirst(); } ``` But when the first object is removed before gc has been collected more than 15 times, this object will be put into the old generation, even if it is removed, it will not be collected by minor gc. This will cause the old generation space to grow until major gc.Is this mechanism rocketmq originally considered? I am worried that major gc in large old gen spacewill cause long STW and cause a large number of messages to fail to be sent in this period.And Can the sampling method be changed to like this? ``` public void samplingInMinutes() { synchronized (this.csListHour) { CallSnapshot cs; if (this.csListHour.size() > 6) { cs = this.csListHour.removeFirst(); cs.setTimes(this.times.get()); cs.setValue(this.value.get()); cs.setTimestamp(System.currentTimeMillis()); } else { cs = new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value.get()); } this.csListHour.add(cs); } } ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
