Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2011-05-13 14:31:13 -0400
committerMarc Khouzam2011-05-13 14:31:13 -0400
commit4bd2d6a68de958cbafe4eeb1d38df1a4911403d3 (patch)
treeff1d68f8f430015d60c937be0efe1b69cb0b6ff9
parent48182ee891c4396429f4e5b4ecd2f11d11ecd247 (diff)
downloadorg.eclipse.cdt-4bd2d6a68de958cbafe4eeb1d38df1a4911403d3.tar.gz
org.eclipse.cdt-4bd2d6a68de958cbafe4eeb1d38df1a4911403d3.tar.xz
org.eclipse.cdt-4bd2d6a68de958cbafe4eeb1d38df1a4911403d3.zip
Bug 323071: Make sure LargePipedInputStream does not leak so that we can run all JUnit tests in a single run.
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java37
1 files changed, 29 insertions, 8 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java
index a03a1b6b2b..5661ac2e29 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java
@@ -67,10 +67,10 @@ public abstract class AbstractCLIProcess extends Process
private final OutputStream fOutputStream = new CLIOutputStream();
// Client process console stream.
- private final PipedInputStream fMIInConsolePipe;
- private final PipedOutputStream fMIOutConsolePipe;
- private final PipedInputStream fMIInLogPipe;
- private final PipedOutputStream fMIOutLogPipe;
+ private PipedInputStream fMIInConsolePipe;
+ private PipedOutputStream fMIOutConsolePipe;
+ private PipedInputStream fMIInLogPipe;
+ private PipedOutputStream fMIOutLogPipe;
private boolean fDisposed = false;
@@ -142,11 +142,26 @@ public abstract class AbstractCLIProcess extends Process
@ConfinedToDsfExecutor("fSession#getExecutor")
public void dispose() {
+ if (fDisposed) return;
+
fCommandControl.removeEventListener(this);
fCommandControl.removeCommandListener(this);
closeIO();
fDisposed = true;
+
+ // We have memory leaks that prevent this class from being
+ // GCed. The problem becomes bad because we are holding
+ // two LargePipedInputStream and eventually, the JUnit tests
+ // run out of memory. To address this particular problem,
+ // before the actual causes of the leaks are fixed, lets
+ // make sure we release all our four streams which all have
+ // a reference to a LargePipedInputStream
+ // Bug 323071
+ fMIInConsolePipe = null;
+ fMIInLogPipe = null;
+ fMIOutConsolePipe = null;
+ fMIOutLogPipe = null;
}
private void closeIO() {
@@ -213,8 +228,10 @@ public abstract class AbstractCLIProcess extends Process
setPrompt(str);
try {
- fMIOutConsolePipe.write(str.getBytes());
- fMIOutConsolePipe.flush();
+ if (fMIOutConsolePipe != null) {
+ fMIOutConsolePipe.write(str.getBytes());
+ fMIOutConsolePipe.flush();
+ }
} catch (IOException e) {
}
} else if (oobr instanceof MILogStreamOutput) {
@@ -222,8 +239,10 @@ public abstract class AbstractCLIProcess extends Process
String str = out.getString();
if (str != null) {
try {
+ if (fMIOutLogPipe != null) {
fMIOutLogPipe.write(str.getBytes());
fMIOutLogPipe.flush();
+ }
} catch (IOException e) {
}
}
@@ -299,8 +318,10 @@ public abstract class AbstractCLIProcess extends Process
// Add a space for readability
String str = SECONDARY_PROMPT + ' ';
try {
- fMIOutConsolePipe.write(str.getBytes());
- fMIOutConsolePipe.flush();
+ if (fMIOutConsolePipe != null) {
+ fMIOutConsolePipe.write(str.getBytes());
+ fMIOutConsolePipe.flush();
+ }
} catch (IOException e) {
}
}

Back to the top