user26093: This is similar to:
Is this function subject to memory fragmentation?
I am trying to get my head around Memory fragmentation in Arduino's and embedded systems in general. 
Currently I have a function in a __lcdAux__ Class which is responsible for doing basic operation on the lcd. 
One of the members of the class is a char array double2StrBuff1 which is used with __dtostrf()__ to create a double which is then passed to sprintf. So the following function (__lcdAux::UpdatePosition__) is responsible for updating the position on the lcd.
void lcdAux::UpdatePosition(double MtXPosLengthUnits) {
    lcd->setCursor(0, 2);
    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);
    sprintf(lcdBuff, "X: %s", double2StrBuff1);
    lcd->print(lcdBuff);
}

Currently, I am under the impression that by defining once the class as a global variable and then using it throughout the program, then the char array is allocated only once memory space. Therefore by using it afterwards no memory fragmentation occurs. 
However, I read that functions allocate space on the stack which is immediately recoved when the function is exited. Therefore I am curious if the following declaration is any different in terms of memory fragmentation.
void lcdAux::UpdatePosition(double MtXPosLengthUnits) {
    lcd->setCursor(0, 2);
    char double2StrBuff1[10];
    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);
    sprintf(lcdBuff, "X: %s", double2StrBuff1);
    lcd->print(lcdBuff);
}

To sum up:

by putting  the declaration for variable __char double2StrBuff1[10];__  inside the function, is the memory allocated from the stack and therefore recovered upon exiting the function (therefore there is no need to declarate a member variable on the class level), 

OR 

is the fact that __double2StrBuff1__ is a pointer means that the pointer is allocated in the stack but the values are located in the heap (therefore what I am doing makes sense)?

PS: Because some might point out that  __"X: %s"__ is worse in terms of memory usage and fragmentation, I'll state the following. Instead of the format string __"X:%s"__ I use a _PROGMEM const char_ array and __strcpy_P()_, but to simplify the question I replaced it with the literal string , since I feel that is another problem. 

user13432: The examples in the question above use 1) global and 2) local aka stack allocation and do not give heap fragmentation. The heap is not involved. 
Below is a version that may give heap fragmentation (though a very low risk): 
void lcdAux::UpdatePosition(double MtXPosLengthUnits) {
    lcd->setCursor(0, 2);
    char* double2StrBuff1 = (char*) malloc(10);
    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);
    sprintf(lcdBuff, "X: %s", double2StrBuff1);
    lcd->print(lcdBuff);
    free(double2StrBuff1);
}

Please not that heap allocation is very slow compared to stack allocation.
C/C++ does not have any implicit heap allocations (in the language). A local array in a function is allocated on the stack and removed when the function returns. The only library functions that can generate stack fragmentation are setjmp and longjmp if used to create a spaghetti stack. 

user7508: 
by putting the declaration for variable char double2StrBuff1[10];
  inside the function, is the memory allocated from the stack and
  therefore recovered upon exiting the function

This is correct.

is the fact that double2StrBuff1 is a pointer means that the pointer
  is allocated in the stack but the values are located in the heap
  (therefore what I am doing makes sense)?

No, double2StrBuff1 is not a pointer, it's an array. In C and C++,
when you use an array identifier, it decays to a pointer in many
situations. However, for the purpose of memory allocation, an array is
very different from a pointer.
Heap allocation only happens when using malloc() and new.

26093: <p>This is similar to:
<a href="https://arduino.stackexchange.com/questions/22319/is-this-function-subject-to-memory-fragmentation">Is this function subject to memory fragmentation?</a></p>

<p>I am trying to get my head around Memory fragmentation in Arduino's and embedded systems in general. </p>

<p>Currently I have a function in a <code>__lcdAux__</code> Class which is responsible for doing basic operation on the lcd. 
One of the members of the class is a char array <code>double2StrBuff1</code> which is used with <code>__dtostrf()__</code> to create a double which is then passed to <code>sprintf</code>. So the following function (<code>__lcdAux::UpdatePosition__</code>) is responsible for updating the position on the lcd.</p>

<pre><code>void lcdAux::UpdatePosition(double MtXPosLengthUnits) {
    lcd-&gt;setCursor(0, 2);
    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);
    sprintf(lcdBuff, "X: %s", double2StrBuff1);
    lcd-&gt;print(lcdBuff);
}
</code></pre>

<p>Currently, I am under the impression that by defining once the class as a global variable and then using it throughout the program, then the char array is allocated only once memory space. Therefore by using it afterwards no memory fragmentation occurs. </p>

<p>However, I read that functions allocate space on the stack which is immediately recoved when the function is exited. Therefore I am curious if the following declaration is any different in terms of memory fragmentation.</p>

<pre><code>void lcdAux::UpdatePosition(double MtXPosLengthUnits) {
    lcd-&gt;setCursor(0, 2);
    char double2StrBuff1[10];
    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);
    sprintf(lcdBuff, "X: %s", double2StrBuff1);
    lcd-&gt;print(lcdBuff);
}
</code></pre>

<p>To sum up:</p>

<ul>
<li>by putting  the declaration for variable <code>__char double2StrBuff1[10];__</code>  inside the function, is the memory allocated from the stack and therefore recovered upon exiting the function (therefore there is no need to declarate a member variable on the class level), </li>
</ul>

<p>OR </p>

<ul>
<li>is the fact that <code>__double2StrBuff1__</code> is a pointer means that the pointer is allocated in the stack but the values are located in the heap (therefore what I am doing makes sense)?</li>
</ul>

<p>PS: Because some might point out that  <code>__"X: %s"__</code> is worse in terms of memory usage and fragmentation, I'll state the following. Instead of the format string <code>__"X:%s"__</code> I use a <code>_PROGMEM</code> const <code>char_ array</code> and <code>__strcpy_P()_</code>, but to simplify the question I replaced it with the literal string , since I feel that is another problem. </p>
 13432: <p>The examples in the question above use 1) global and 2) local aka stack allocation and do not give heap fragmentation. The heap is not involved. </p>

<p>Below is a version that may give heap fragmentation (though a very low risk): </p>

<pre><code>void lcdAux::UpdatePosition(double MtXPosLengthUnits) {
    lcd-&gt;setCursor(0, 2);
    char* double2StrBuff1 = (char*) malloc(10);
    dtostrf(MtXPosLengthUnits, 0,3, double2StrBuff1);
    sprintf(lcdBuff, "X: %s", double2StrBuff1);
    lcd-&gt;print(lcdBuff);
    free(double2StrBuff1);
}
</code></pre>

<p>Please not that heap allocation is very slow compared to stack allocation.</p>

<p>C/C++ does not have any implicit heap allocations (in the language). A local array in a function is allocated on the stack and removed when the function returns. The only library functions that can generate stack fragmentation are <a href="http://www.nongnu.org/avr-libc/user-manual/group__setjmp.html" rel="nofollow">setjmp and longjmp</a> if used to create a <a href="http://c2.com/cgi/wiki?SpaghettiStack" rel="nofollow">spaghetti stack</a>. </p>
 7508: <blockquote>
  <p>by putting the declaration for variable char double2StrBuff1[10];
  inside the function, is the memory allocated from the stack and
  therefore recovered upon exiting the function</p>
</blockquote>

<p>This is correct.</p>

<blockquote>
  <p>is the fact that double2StrBuff1 is a pointer means that the pointer
  is allocated in the stack but the values are located in the heap
  (therefore what I am doing makes sense)?</p>
</blockquote>

<p>No, <code>double2StrBuff1</code> is not a pointer, it's an array. In C and C++,
when you use an array identifier, it decays to a pointer in many
situations. However, for the purpose of memory allocation, an array is
<em>very different</em> from a pointer.</p>

<p>Heap allocation only happens when using <code>malloc()</code> and <code>new</code>.</p>
