* Extract collection clearing in commit() and abort() into new recycle() method,
and throw away collections in order to avoid retaining too much memory.
This commit is contained in:
parent
7e00def51c
commit
d843138386
1 changed files with 24 additions and 12 deletions
|
@ -113,7 +113,7 @@ public class Transactor extends Thread {
|
||||||
/**
|
/**
|
||||||
* Keep a reference to an unmodified Node local to this transaction
|
* Keep a reference to an unmodified Node local to this transaction
|
||||||
*
|
*
|
||||||
* @param node ...
|
* @param node the node to register
|
||||||
*/
|
*/
|
||||||
public void visitCleanNode(Node node) {
|
public void visitCleanNode(Node node) {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
@ -128,8 +128,8 @@ public class Transactor extends Thread {
|
||||||
/**
|
/**
|
||||||
* Keep a reference to an unmodified Node local to this transaction
|
* Keep a reference to an unmodified Node local to this transaction
|
||||||
*
|
*
|
||||||
* @param key ...
|
* @param key the key to register with
|
||||||
* @param node ...
|
* @param node the node to register
|
||||||
*/
|
*/
|
||||||
public void visitCleanNode(Key key, Node node) {
|
public void visitCleanNode(Key key, Node node) {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
@ -227,11 +227,11 @@ public class Transactor extends Thread {
|
||||||
dirtyNodes.clear();
|
dirtyNodes.clear();
|
||||||
cleanNodes.clear();
|
cleanNodes.clear();
|
||||||
parentNodes.clear();
|
parentNodes.clear();
|
||||||
|
testedConnections.clear();
|
||||||
txn = nmgr.db.beginTransaction();
|
txn = nmgr.db.beginTransaction();
|
||||||
active = true;
|
active = true;
|
||||||
tstart = System.currentTimeMillis();
|
tstart = System.currentTimeMillis();
|
||||||
tname = name;
|
tname = name;
|
||||||
testedConnections.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -353,10 +353,7 @@ public class Transactor extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the node collections
|
// clear the node collections
|
||||||
dirtyNodes.clear();
|
recycle();
|
||||||
cleanNodes.clear();
|
|
||||||
parentNodes.clear();
|
|
||||||
testedConnections.clear();
|
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
active = false;
|
active = false;
|
||||||
|
@ -398,10 +395,7 @@ public class Transactor extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the node collections
|
// clear the node collections
|
||||||
dirtyNodes.clear();
|
recycle();
|
||||||
cleanNodes.clear();
|
|
||||||
parentNodes.clear();
|
|
||||||
testedConnections.clear();
|
|
||||||
|
|
||||||
// close any JDBC connections associated with this transactor thread
|
// close any JDBC connections associated with this transactor thread
|
||||||
closeConnections();
|
closeConnections();
|
||||||
|
@ -470,6 +464,24 @@ public class Transactor extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear collections and throw them away. They may have grown large,
|
||||||
|
* so the benefit of keeping them (less GC) needs to be weighted against
|
||||||
|
* the potential increas in memory usage.
|
||||||
|
*/
|
||||||
|
private synchronized void recycle() {
|
||||||
|
// clear the node collections to ease garbage collection
|
||||||
|
dirtyNodes.clear();
|
||||||
|
cleanNodes.clear();
|
||||||
|
parentNodes.clear();
|
||||||
|
testedConnections.clear();
|
||||||
|
// create new collections
|
||||||
|
dirtyNodes = new HashMap();
|
||||||
|
cleanNodes = new HashMap();
|
||||||
|
parentNodes = new HashSet();
|
||||||
|
testedConnections = new HashSet();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the current transaction. This is usually the request
|
* Return the name of the current transaction. This is usually the request
|
||||||
* path for the underlying HTTP request.
|
* path for the underlying HTTP request.
|
||||||
|
|
Loading…
Add table
Reference in a new issue