title: Why Android Studio profiler heap dump showing about 7x overhead for an arraylist?
body: <p>I was wondering and testing object's memory allocation on Android/Java and found something strange happening on heap, well maybe it's just normal.</p>
  <p>Here is what i did and found; there is a txt data file that 850kb in file size with 26220 lines, 30 chars per line. I get all lines via inputstream and add them to an arraylist. Then i dump heap on Android Studio profiler and as you can see on screenshot, heap dump looks like counting all related objects separately and adding them all making 7x larger memory size than actual text data. Normally app heap's total retained size is 2.8MB before, after creating the arraylist it gets about 9MB, so it makes 6.2MB memory size for a 0.85MB text data. Is this behavior completely normal in Android/Java or something wrong with profiler?<br />
  Thanks all in advance.</p>
  <p><a href="https://i.stack.imgur.com/cAJN2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cAJN2.jpg" alt="profiler heap screenshot" /></a></p>
  <p>UPDATE</p>
  <p>I took another screenshot this time from Android Studio's memory profiler histogram not from heap dump. It's interesting it's showing memory consumption as expected or at least not abnormal on this histogram unlike misleading/confusing heap dump. As you can see on the screenshot, before creating arraylist, total consumed memory by application is 34.5MB and Java memory (supposed to be heap) is 5.2MB. After creating the arraylist from 850KB raw text file, total memory becomes 37MB and Java 7.1MB making 2.5MB total memory and 1.9MB heap memory difference.</p>
  <p>It seems like retained size information on Android Studio's heap dump is misleading and should be ignored as suggested by Andreas.</p>
  <p><a href="https://i.stack.imgur.com/RdodD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RdodD.jpg" alt="screenshot 2" /></a></p>