Commit dbb46fc2 authored by Lenard Nagy's avatar Lenard Nagy
Browse files

OutOfMemory checking can be disabled on On-The-Fyly preferences page. By default it is switched on.


Signed-off-by: Lenard Nagy's avatarLenard Nagy (elnrnag) <lenard.nagy@ericsson.com>
parent 0be5886e
......@@ -72,19 +72,22 @@ public class OutOfMemoryCheck {
* @return true: if the remaining free memory is low
* */
public static boolean isOutOfMemory() {
Runtime Rt = Runtime.getRuntime();
if (Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.CHECKFORLOWMEMORY)) {
Runtime Rt = Runtime.getRuntime();
long free = Rt.freeMemory();
long total = Rt.totalMemory();
long free = Rt.freeMemory();
long total = Rt.totalMemory();
long limit = Math.min(200000000, Math.round(total * (double)0.10));
ErrorReporter.logError("limit: "+String.valueOf(limit)+", free: " + String.valueOf(free));
if (free < limit) {
long limit = Math.min(200000000, Math.round(total * (double)0.1));
ErrorReporter.logError("limit: "+String.valueOf(limit)+", free: " + String.valueOf(free));
return true;
if (free < limit) {
ErrorReporter.logError("limit: "+String.valueOf(limit)+", free: " + String.valueOf(free));
return true;
} else {
return false;
}
} else {
return false;
}
}
}
......@@ -20,6 +20,7 @@ public final class PreferenceConstants {
public static final String ONTHEFLYMARKERSAFTERCOMPILER = ProductConstants.PRODUCT_ID_DESIGNER + ".ontheflyMarkersAfterCompiler";
public static final String REPORTPROGRAMERRORWITHMARKER = ProductConstants.PRODUCT_ID_DESIGNER + ".reportProgramErrorWithMarker";
public static final String TREATONTHEFLYERRORSFATALFORBUILD = ProductConstants.PRODUCT_ID_DESIGNER + ".treatOnTheFlyErrorsasFatalForBuild";
public static final String CHECKFORLOWMEMORY = ProductConstants.PRODUCT_ID_DESIGNER + ".checkForLowMemory";
public static final String USEONTHEFLYPARSING = ProductConstants.PRODUCT_ID_DESIGNER + ".useOnTheFlyParsing";
public static final String USEINCREMENTALPARSING = ProductConstants.PRODUCT_ID_DESIGNER + ".useIncrementalParsing";
public static final String DELAYSEMANTICCHECKINGTILLSAVE = ProductConstants.PRODUCT_ID_DESIGNER + ".delaySemantiCheckingTillSave";
......
......@@ -39,6 +39,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
preferenceStore.setDefault(PreferenceConstants.ONTHEFLYMARKERSAFTERCOMPILER, PreferenceConstantValues.ONTHEFLYOPTIONSTAY);
preferenceStore.setDefault(PreferenceConstants.REPORTPROGRAMERRORWITHMARKER, false);
preferenceStore.setDefault(PreferenceConstants.TREATONTHEFLYERRORSFATALFORBUILD, false);
preferenceStore.setDefault(PreferenceConstants.CHECKFORLOWMEMORY, true);
preferenceStore.setDefault(PreferenceConstants.USEONTHEFLYPARSING, true);
preferenceStore.setDefault(PreferenceConstants.USEINCREMENTALPARSING, false);
preferenceStore.setDefault(PreferenceConstants.DELAYSEMANTICCHECKINGTILLSAVE, true);
......
......@@ -27,6 +27,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
public final class OnTheFlyCheckerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
private static final String DESCRIPTION = "Preferences of the on-the-fly checker";
private static final String CHECK_MEMORY = "Warn and disable parsing before the system runs out of memory";
private static final String ENABLE_PARSING = "Enable parsing of TTCN-3, ASN.1 and Runtime Configuration files";
private static final String ENABLE_INCREMENTAL_PARSING = "Enable the incremental parsing of TTCN-3 files (EXPERIMENTAL)";
private static final String MINIMISE_MEMORY_USAGE = "Minimise memory usage";
......@@ -34,6 +35,7 @@ public final class OnTheFlyCheckerPreferencePage extends FieldEditorPreferencePa
private static final String RECONCILER_TIMEOUT = "Timeout in seconds before on-the-fly check starts";
private Composite composite;
private BooleanFieldEditor checkForLowMemory;
private BooleanFieldEditor useOnTheFlyParsing;
private BooleanFieldEditor useIncrementalParsing;
// private BooleanFieldEditor minimiseMemoryUsage;
......@@ -50,6 +52,9 @@ public final class OnTheFlyCheckerPreferencePage extends FieldEditorPreferencePa
protected void createFieldEditors() {
Composite tempParent = getFieldEditorParent();
checkForLowMemory = new BooleanFieldEditor(PreferenceConstants.CHECKFORLOWMEMORY, CHECK_MEMORY, tempParent);
addField(checkForLowMemory);
useOnTheFlyParsing = new BooleanFieldEditor(PreferenceConstants.USEONTHEFLYPARSING, ENABLE_PARSING, tempParent);
addField(useOnTheFlyParsing);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment