title: Empty Swift string Memory allocation Layout (Stack/ Heap allocation)
body: <p>In swift, strings are struct types, so the values are going to be stored in stack memory rather than the heap.</p>
  
  <p>Lets say we declare a string:</p>
  
  <pre><code>let a = ""
  let b = "o"
  </code></pre>
  
  <p>This is an empty string, but some memory is allocated. I need to know what is the difference in the memory given to an empty string and a string with let's say count 1.</p>
  
  <hr>
  
  <p>If we say:-</p>
  
  <pre><code>var str:String?
  var str: String = ""
  </code></pre>
  
  <p>The difference in memory layout by drawing is what I need to see. (stack / heap).</p>
  
  <p>I tried to find this on google but nowhere I can't find the memory layout for this.</p>