Skip to content

Commit 090f721

Browse files
committed
Clarified error messages and added a configurable warning level
Changed memory usage check to only fail build on 100%+ usage and added a configurable warning level for memory usage defaulting to 75%. Clarified error and warning messages related to memory usage to specify that this is the minimum memory usage.
1 parent c35e57a commit 090f721

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Diff for: app/src/processing/app/Sketch.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -1634,11 +1634,11 @@ protected void size(PreferencesMap prefs) throws RunnerException {
16341634
if(dataSize >= 0) {
16351635
if(maxDataSize > 0) {
16361636
System.out.println(I18n
1637-
.format(_("Memory usage: {0} bytes (of a {1} byte maximum) - {2}% used"),
1637+
.format(_("Minimum Memory usage: {0} bytes (of a {1} byte maximum) - {2}% used"),
16381638
dataSize, maxDataSize, dataSize * 100 / maxDataSize));
16391639
} else {
16401640
System.out.println(I18n
1641-
.format(_("Memory usage: {0} bytes"),
1641+
.format(_("Minimum Memory usage: {0} bytes"),
16421642
dataSize));
16431643
}
16441644
}
@@ -1647,11 +1647,17 @@ protected void size(PreferencesMap prefs) throws RunnerException {
16471647
e.getMessage()));
16481648
}
16491649

1650-
/* At least 10% of RAM should be reserved for stack/heap usage */
1651-
if (textSize > maxTextSize ||
1652-
(maxDataSize > 0 && dataSize > maxDataSize*9/10))
1650+
if (textSize > maxTextSize)
16531651
throw new RunnerException(
16541652
_("Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it."));
1653+
1654+
if (maxDataSize > 0 && dataSize > maxDataSize)
1655+
throw new RunnerException(
1656+
_("Not enough memory; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing your footprint."));
1657+
1658+
int warnDataPercentage = Integer.parseInt(prefs.get("build.warn_data_percentage"));
1659+
if (maxDataSize > 0 && dataSize > maxDataSize*warnDataPercentage/100)
1660+
System.out.println(_("Low memory available, stability problems may occur"));
16551661
}
16561662

16571663
protected String upload(String buildPath, String suggestedClassName, boolean usingProgrammer)

Diff for: build/shared/lib/preferences.txt

+2
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ target_package = arduino
246246
target_platform = avr
247247
board = uno
248248
software=ARDUINO
249+
# Warn when data segment uses greater than this percentage
250+
build.warn_data_percentage = 75
249251

250252
programmer = arduino:avrispmkii
251253

0 commit comments

Comments
 (0)