You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2006/09/01 13:58:53 UTC
svn commit: r439281 - in
/db/derby/code/branches/10.2/java/engine/org/apache/derby:
iapi/services/loader/ iapi/sql/conn/ impl/sql/conn/ impl/sql/execute/
Author: kahatlen
Date: Fri Sep 1 04:58:52 2006
New Revision: 439281
URL: http://svn.apache.org/viewvc?rev=439281&view=rev
Log:
DERBY-418: outofmemory error when running large query in autocommit=false mode
DERBY-1142: Metadata calls leak memory
Merged fix from trunk.
Modified:
db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/services/loader/GeneratedByteCode.java
db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/services/loader/GeneratedByteCode.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/services/loader/GeneratedByteCode.java?rev=439281&r1=439280&r2=439281&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/services/loader/GeneratedByteCode.java (original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/services/loader/GeneratedByteCode.java Fri Sep 1 04:58:52 2006
@@ -35,7 +35,8 @@
Called by the class manager just after
creating the instance of the new class.
*/
- public void initFromContext(Context context);
+ public void initFromContext(Context context)
+ throws StandardException;
/**
Set the Generated Class. Call by the class manager just after
Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java?rev=439281&r1=439280&r2=439281&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java (original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java Fri Sep 1 04:58:52 2006
@@ -143,7 +143,13 @@
* Add the activation to those known about by this connection.
*
*/
- void addActivation(Activation a);
+ void addActivation(Activation a)
+ throws StandardException;
+
+ /**
+ * Make a note that some activations are marked unused
+ */
+ void notifyUnusedActivation();
/**
* Remove the activation from those known about by this connection.
Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=439281&r1=439280&r2=439281&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java (original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java Fri Sep 1 04:58:52 2006
@@ -116,6 +116,7 @@
*/
private final Vector acts;
+ private volatile boolean unusedActs=false;
protected int bindCount;
private boolean ddWriteMode;
private boolean runTimeStatisticsSetting ;
@@ -429,9 +430,32 @@
/**
* Add the activation to those known about by this connection.
*/
- public void addActivation(Activation a) {
+ public void addActivation(Activation a)
+ throws StandardException {
acts.addElement(a);
+ // DERBY-418. Activations which are marked unused,
+ // are closed here. Activations Vector is iterated
+ // to identify and close unused activations, only if
+ // unusedActs flag is set to true and if the total
+ // size exceeds 20.
+ if( (unusedActs) && (acts.size() > 20) ) {
+ unusedActs = false;
+ for (int i = acts.size() - 1; i >= 0; i--) {
+
+ // it maybe the case that a Activation's reset() ends up
+ // closing one or more activation leaving our index beyond
+ // the end of the array
+ if (i >= acts.size())
+ continue;
+
+ Activation a1 = (Activation) acts.elementAt(i);
+ if (!a1.isInUse()) {
+ a1.close();
+ }
+ }
+ }
+
if (SanityManager.DEBUG) {
if (SanityManager.DEBUG_ON("memoryLeakTrace")) {
@@ -440,6 +464,13 @@
System.out.println("memoryLeakTrace:GenericLanguageContext:activations " + acts.size());
}
}
+ }
+
+ /**
+ * Make a note that some activations are marked unused
+ */
+ public void notifyUnusedActivation() {
+ unusedActs = true;
}
/**
Modified: db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java?rev=439281&r1=439280&r2=439281&view=diff
==============================================================================
--- db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java (original)
+++ db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java Fri Sep 1 04:58:52 2006
@@ -125,7 +125,10 @@
protected int numSubqueries;
private boolean singleExecution;
- private boolean inUse;
+
+ // This flag is declared volatile to ensure it is
+ // visible when it has been modified by the finalizer thread.
+ private volatile boolean inUse;
private java.sql.ResultSet targetVTI;
private SQLWarning warnings;
@@ -192,7 +195,8 @@
super();
}
- public final void initFromContext(Context context) {
+ public final void initFromContext(Context context)
+ throws StandardException {
if (SanityManager.DEBUG)
{
@@ -786,7 +790,10 @@
*/
public final void markUnused()
{
- inUse = false;
+ if(isInUse()) {
+ inUse = false;
+ lcc.notifyUnusedActivation();
+ }
}
/**