1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 02:06:01 +02:00

Applied patch in: [236838] Cannot view large array variables due to OutOfMemoryError.

This commit is contained in:
John Cortell 2009-10-13 18:40:51 +00:00
parent 892e506a8e
commit df80ee1b69

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.core.IAddressFactory;
@ -36,9 +38,10 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
private ICDIArrayValue fCDIValue; private ICDIArrayValue fCDIValue;
/** /**
* List of child variables. * Child variables. Only the variables from loaded partitions will be held.
* Use map instead of a java array to scale for large number of children.
*/ */
private IVariable[] fVariables; private Map<Integer, IVariable> fVariables;
/** /**
* The index of the first variable contained in this value. * The index of the first variable contained in this value.
@ -60,7 +63,7 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
*/ */
public CIndexedValue( AbstractCVariable parent, ICDIArrayValue cdiValue, int offset, int size ) { public CIndexedValue( AbstractCVariable parent, ICDIArrayValue cdiValue, int offset, int size ) {
super( parent ); super( parent );
fVariables = new IVariable[ size ]; fVariables = new HashMap<Integer, IVariable>(getPreferredPartitionSize());
fCDIValue = cdiValue; fCDIValue = cdiValue;
fOffset = offset; fOffset = offset;
fSize = size; fSize = size;
@ -70,10 +73,8 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#setChanged(boolean) * @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#setChanged(boolean)
*/ */
protected void setChanged( boolean changed ) { protected void setChanged( boolean changed ) {
for ( int i = 0; i < fVariables.length; ++i ) { for (IVariable var : fVariables.values()) {
if ( fVariables[i] != null ) { ((AbstractCVariable)var).setChanged( changed );
((AbstractCVariable)fVariables[i]).setChanged( changed );
}
} }
} }
@ -81,10 +82,8 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#dispose() * @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#dispose()
*/ */
public void dispose() { public void dispose() {
for ( int i = 0; i < fVariables.length; ++i ) { for (IVariable var : fVariables.values()) {
if ( fVariables[i] != null ) { ((AbstractCVariable)var).dispose();
((AbstractCVariable)fVariables[i]).dispose();
}
} }
} }
@ -92,10 +91,8 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#reset() * @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#reset()
*/ */
protected void reset() { protected void reset() {
for ( int i = 0; i < fVariables.length; ++i ) { for (IVariable var : fVariables.values()) {
if ( fVariables[i] != null ) { ((AbstractCVariable)var).resetValue();
((AbstractCVariable)fVariables[i]).resetValue();
}
} }
} }
@ -104,10 +101,8 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
*/ */
protected void preserve() { protected void preserve() {
resetStatus(); resetStatus();
for ( int i = 0; i < fVariables.length; ++i ) { for (IVariable var : fVariables.values()) {
if ( fVariables[i] != null ) { ((AbstractCVariable)var).preserve();
((AbstractCVariable)fVariables[i]).preserve();
}
} }
} }
@ -262,12 +257,14 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
} }
} }
} }
System.arraycopy( fVariables, offset, result, 0, length ); for (int i = 0; i < length; i++) {
result[i] = fVariables.get( offset + i );
}
return result; return result;
} }
private boolean isPartitionLoaded( int index ) { private boolean isPartitionLoaded( int index ) {
return fVariables[index * getPreferredPartitionSize()] != null; return fVariables.containsKey(index * getPreferredPartitionSize());
} }
private void loadPartition( int index ) throws DebugException { private void loadPartition( int index ) throws DebugException {
@ -281,7 +278,7 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
requestFailed( e.getMessage(), null ); requestFailed( e.getMessage(), null );
} }
for( int i = 0; i < cdiVars.length; ++i ) for( int i = 0; i < cdiVars.length; ++i )
fVariables[i + index * prefSize] = CVariableFactory.createLocalVariable( this, cdiVars[i] ); fVariables.put(i + index * prefSize, CVariableFactory.createLocalVariable( this, cdiVars[i] ));
} }
private int getSize0() { private int getSize0() {