Home > Back-end >  Why the Timer timing task runtime memory has been increased
Why the Timer timing task runtime memory has been increased

Time:05-28


Code as shown in figure, a simple single thread monitoring data storage program, the Timer's run () method calls the three methods, the first two methods return, introduced into the third method to send mail,
Startup of around 50 m, memory and slow growth, although growth is slow, but sooner or later, overflow, if it is running on the server can't imagine,
Please answer ~

CodePudding user response:

Code not whole, through the analysis of the description, may be a more and more data in a collection objects, not cleaning mechanism, memory is slow growth probability is that
In view of the public list code, set, map, etc., if the data is to add, need to have regular cleaning mechanism or backup mechanism, such as more than how much, brush all the data to the database or redis or file, and then clean off the original collection

CodePudding user response:

You see that no one can help you

CodePudding user response:

Use jprofile look at heap, and see which objects are not gc

CodePudding user response:

reference 1/f, one born in response:
code didn't stick all, through the analysis of the description, may be a more and more data in a collection objects, not cleaning mechanism, memory is slow growth probability is that
In view of the public list code, set, map, etc., if the data is to add, need to have regular cleaning mechanism or backup mechanism, such as more than how much, brush all the data to the database or redis or file, and then clean off the original collection

Thank you for answer, the public collection is a subdirectory in the directory name, few in number, and run once a day, don't run will not modify,

CodePudding user response:

reference 1/f, one born in response:
code didn't stick all, through the analysis of the description, may be a more and more data in a collection objects, not cleaning mechanism, memory is slow growth probability is that
In view of the public list code, set, map, etc., if the data is to add, need to have regular cleaning mechanism or backup mechanism, such as more than how much, brush all the data to the database or redis or file, and then clean off the original collection

Yesterday when you use the Timer usage is wrong, only passed the first run time, mistakenly assume that automatic identification for this point in time, every day no incoming frequencies, the next day at memory reached 400 m,
Just added frequency parameters, local test found that the problem was solved, reach to start going down after about 60 m peak, now on the server to look for a period of time,
It is quite strange, only to start for the first time the time is not equivalent to running a ends, why no exit program,

CodePudding user response:

reference 3 floor seven sea my wife's reply:
with jprofile look at heap, and see which objects are not gc

Ok, I will monitor it, thanks
  • Related