https://issues.apache.org/jira/browse/AMQ-3162 - ActiveMQ checkpoint worker makes unnecessary repeated calls to Journal.getFileMap(), leading to excessive memory usage

applied variation of the patch with thanks. Now make one call to find the current set of referenced files.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1063669 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-01-26 10:40:35 +00:00
parent ed6a4c7067
commit 62609f099a
1 changed files with 4 additions and 3 deletions

View File

@ -1137,8 +1137,9 @@ public class MessageDatabase extends ServiceSupport implements BrokerServiceAwar
pageFile.flush();
if( cleanup ) {
final TreeSet<Integer> gcCandidateSet = new TreeSet<Integer>(journal.getFileMap().keySet());
final TreeSet<Integer> completeFileSet = new TreeSet<Integer>(journal.getFileMap().keySet());
final TreeSet<Integer> gcCandidateSet = new TreeSet<Integer>(completeFileSet);
// Don't GC files under replication
if( journalFilesBeingReplicated!=null ) {
@ -1220,7 +1221,7 @@ public class MessageDatabase extends ServiceSupport implements BrokerServiceAwar
Set<Integer> referencedFileIds = ackMessageFileMap.get(candidate);
if (referencedFileIds != null) {
for (Integer referencedFileId : referencedFileIds) {
if (journal.getFileMap().containsKey(referencedFileId) && !gcCandidates.contains(referencedFileId)) {
if (completeFileSet.contains(referencedFileId) && !gcCandidates.contains(referencedFileId)) {
// active file that is not targeted for deletion is referenced so don't delete
candidates.remove();
break;