* Fix a potential memory leak: Don't allow entries list to grow indefinitely.
If the list reaches a certain size (2000 entries), further entries are discarded.
This commit is contained in:
parent
e41f6c02f1
commit
34b1a8641a
1 changed files with 5 additions and 2 deletions
|
@ -129,8 +129,11 @@ public class Logger implements Log {
|
|||
if ((System.currentTimeMillis() - 1000) > dateLastRendered) {
|
||||
renderDate();
|
||||
}
|
||||
|
||||
entries.add(dateCache + msg);
|
||||
// add a safety net so we don't grow indefinitely even if writer thread
|
||||
// has gone. the 2000 entries threshold is somewhat arbitrary.
|
||||
if (entries.size() < 2000) {
|
||||
entries.add(dateCache + msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue