Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 323071
Collapse All | Expand All

(-)src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java (-8 / +29 lines)
Lines 67-76 Link Here
67
	private final OutputStream fOutputStream = new CLIOutputStream();
67
	private final OutputStream fOutputStream = new CLIOutputStream();
68
    
68
    
69
    // Client process console stream.
69
    // Client process console stream.
70
    private final PipedInputStream fMIInConsolePipe;
70
    private PipedInputStream fMIInConsolePipe;
71
    private final PipedOutputStream fMIOutConsolePipe;
71
    private PipedOutputStream fMIOutConsolePipe;
72
    private final PipedInputStream fMIInLogPipe;
72
    private PipedInputStream fMIInLogPipe;
73
    private final PipedOutputStream fMIOutLogPipe;
73
    private PipedOutputStream fMIOutLogPipe;
74
74
75
    private boolean fDisposed = false;
75
    private boolean fDisposed = false;
76
    
76
    
Lines 142-152 Link Here
142
	
142
	
143
    @ConfinedToDsfExecutor("fSession#getExecutor")
143
    @ConfinedToDsfExecutor("fSession#getExecutor")
144
    public void dispose() {
144
    public void dispose() {
145
    	if (fDisposed) return;
146
    	
145
        fCommandControl.removeEventListener(this);
147
        fCommandControl.removeEventListener(this);
146
        fCommandControl.removeCommandListener(this);
148
        fCommandControl.removeCommandListener(this);
147
        
149
        
148
        closeIO();
150
        closeIO();
149
        fDisposed = true;
151
        fDisposed = true;
152
153
        // We have memory leaks that prevent this class from being
154
        // GCed.  The problem becomes bad because we are holding
155
        // two LargePipedInputStream and eventually, the JUnit tests
156
        // run out of memory.  To address this particular problem,
157
        // before the actual causes of the leaks are fixed, lets
158
        // make sure we release all our four streams which all have
159
        // a reference to a LargePipedInputStream
160
        // Bug 323071
161
        fMIInConsolePipe = null;
162
        fMIInLogPipe = null;
163
        fMIOutConsolePipe = null;
164
        fMIOutLogPipe = null;
150
    }
165
    }
151
    
166
    
152
    private void closeIO() {
167
    private void closeIO() {
Lines 213-220 Link Here
213
228
214
                setPrompt(str);
229
                setPrompt(str);
215
                try {
230
                try {
216
                    fMIOutConsolePipe.write(str.getBytes());
231
                	if (fMIOutConsolePipe != null) {
217
                    fMIOutConsolePipe.flush();
232
                		fMIOutConsolePipe.write(str.getBytes());
233
                		fMIOutConsolePipe.flush();
234
                	}
218
                } catch (IOException e) {
235
                } catch (IOException e) {
219
                }
236
                }
220
            } else if (oobr instanceof MILogStreamOutput) {
237
            } else if (oobr instanceof MILogStreamOutput) {
Lines 222-229 Link Here
222
                String str = out.getString();
239
                String str = out.getString();
223
                if (str != null) {
240
                if (str != null) {
224
                    try {
241
                    try {
242
                    	if (fMIOutLogPipe != null) {
225
	                        fMIOutLogPipe.write(str.getBytes());
243
	                        fMIOutLogPipe.write(str.getBytes());
226
	                        fMIOutLogPipe.flush();
244
	                        fMIOutLogPipe.flush();
245
                    	}
227
                    } catch (IOException e) {
246
                    } catch (IOException e) {
228
                    }
247
                    }
229
                }
248
                }
Lines 299-306 Link Here
299
                	// Add a space for readability
318
                	// Add a space for readability
300
                	String str = SECONDARY_PROMPT + ' ';
319
                	String str = SECONDARY_PROMPT + ' ';
301
    				try {
320
    				try {
302
    					fMIOutConsolePipe.write(str.getBytes());
321
                    	if (fMIOutConsolePipe != null) {
303
    					fMIOutConsolePipe.flush();
322
                    		fMIOutConsolePipe.write(str.getBytes());
323
                    		fMIOutConsolePipe.flush();
324
                    	}
304
    				} catch (IOException e) {
325
    				} catch (IOException e) {
305
    				}
326
    				}
306
    			}
327
    			}

Return to bug 323071