title: Would encoding a string take less memory?
body: <p>I am confused about memory space topic. Lets say we have a following string:</p>
  
  <pre><code>String from = "Hello I am from Chicago";
  </code></pre>
  
  <p>If I encode it using Huffman Coding, LZ4, or GZip, etc. (the encoding algorithm does not matter at this point): </p>
  
  <pre><code>String encodedFrom= encodingLibrary.encode(from);
  </code></pre>
  
  <p>Now, the amount of memory space <code>encodedName</code> would hold, would be less than what <code>name</code> would have taken?</p>
  
  <p>I am confused because, when we are storing strings, even if there are less bits, VM (or OS itself, or something) would add padding to the end to finish the byte. Something like that. So at the end of the day the memory size (not consumption) is same for both encoded and <strong>un</strong>-encoded String. Am I right to think that?</p>
  
  <p>2nd question related to first one, I in fact want to encode 100s of thousands of records and store it in Redis cache. how would that play out, if we exclude time it takes for compression/decompression and memory consumption factors? Encoded string would take up less space in Redis cache?</p>
  
  <p>Appreciate any help.</p>