user31105: I have the following output of my sketch for the Arduino Mega so far:
Sketch uses 25020 bytes (9%) of program storage space. Maximum is 253952 bytes.
Global variables use 6919 bytes (84%) of dynamic memory, leaving 1273 bytes for
local variables. Maximum is 8192 bytes.

Low memory available, stability problems may occur.

I think 1273 bytes is not so less for most sketches, although mine is quite big (several thousand of lines, and I'm about half).
I was wondering if the IDE is so smart to statically analyze my code to see what my dynamic storage is (about 600 bytes) and/or calculates some expected stack size (several hundred bytes at least).
Or is it just a (very) safe fixed or percentage-based value? 

user31105: I just did some tests and found the answer.
char a[6135];

void setup() 
{
  a[0] = 0;
}

void loop() 
{
}

This sketch does not give a warning:
Sketch uses 660 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 6144 bytes (75%) of dynamic memory, leaving 2048 bytes for local variables. Maximum is 8192 bytes.

If I increase the array with 1, I get an error:
Sketch uses 660 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 6145 bytes (75%) of dynamic memory, leaving 2047 bytes for local variables. Maximum is 8192 bytes.
Low memory available, stability problems may occur.

Conclusion: below 2 KB (2048 bytes) of free space, the warning is shown.
I did the same test for the Uno, and there the warning is shown when less than 1536 bytes are free.
Both percentages are 75%, so the end conclusion is that the value is based on 75% of memory.

31105: <p>I have the following output of my sketch for the Arduino Mega so far:</p>

<pre><code>Sketch uses 25020 bytes (9%) of program storage space. Maximum is 253952 bytes.
Global variables use 6919 bytes (84%) of dynamic memory, leaving 1273 bytes for
local variables. Maximum is 8192 bytes.

Low memory available, stability problems may occur.
</code></pre>

<p>I think 1273 bytes is not so less for most sketches, although mine is quite big (several thousand of lines, and I'm about half).</p>

<p>I was wondering if the IDE is so smart to statically analyze my code to see what my dynamic storage is (about 600 bytes) and/or calculates some expected stack size (several hundred bytes at least).</p>

<p>Or is it just a (very) safe fixed or percentage-based value? </p>
 31105: <p>I just did some tests and found the answer.</p>

<pre><code>char a[6135];

void setup() 
{
  a[0] = 0;
}

void loop() 
{
}
</code></pre>

<p>This sketch does not give a warning:</p>

<pre><code>Sketch uses 660 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 6144 bytes (75%) of dynamic memory, leaving 2048 bytes for local variables. Maximum is 8192 bytes.
</code></pre>

<p>If I increase the array with 1, I get an error:</p>

<pre><code>Sketch uses 660 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 6145 bytes (75%) of dynamic memory, leaving 2047 bytes for local variables. Maximum is 8192 bytes.
Low memory available, stability problems may occur.
</code></pre>

<p>Conclusion: below 2 KB (2048 bytes) of free space, the warning is shown.</p>

<p>I did the same test for the Uno, and there the warning is shown when less than 1536 bytes are free.</p>

<p>Both percentages are 75%, so the end conclusion is that the value is based on 75% of memory.</p>
