<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Aptos",sans-serif;
        mso-ligatures:standardcontextual;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#467886;
        text-decoration:underline;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="en-DE" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hi Kenneth,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The answers to most of these questions are, “No, this is not how it works in any modern JVM”.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I would really recommend playing with JOL, especially look through its Samples:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="https://github.com/openjdk/jol">https://github.com/openjdk/jol</a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="https://github.com/openjdk/jol/tree/master/jol-samples/src/main/java/org/openjdk/jol/samples">https://github.com/openjdk/jol/tree/master/jol-samples/src/main/java/org/openjdk/jol/samples</a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">And maybe read this for even more discussion:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="https://shipilev.net/jvm/objects-inside-out/">https://shipilev.net/jvm/objects-inside-out/</a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">-Aleksey<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-CA" style="font-size:12.0pt;font-family:"Calibri",sans-serif;color:black;mso-ligatures:none;mso-fareast-language:EN-GB">From:
</span></b><span lang="EN-CA" style="font-size:12.0pt;font-family:"Calibri",sans-serif;color:black;mso-ligatures:none;mso-fareast-language:EN-GB">discuss <discuss-retn@openjdk.org> on behalf of Kenneth Fogel <kfogel@dawsoncollege.qc.ca><br>
<b>Date: </b>Friday, 8. August 2025 at 18:11<br>
<b>To: </b>"discuss@openjdk.org" <discuss@openjdk.org><br>
<b>Subject: </b>[EXTERNAL] Memory Usage in Java<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:12.0pt;mso-ligatures:none;mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
</div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse">
<tbody>
<tr style="height:15.25pt">
<td width="1123" valign="top" style="width:842.35pt;border:solid #ED7D31 1.5pt;padding:0cm 5.4pt 0cm 5.4pt;height:15.25pt">
<p><strong><span style="font-family:"Aptos",sans-serif;color:black;background:#FFFF99">CAUTION</span></strong><span style="color:black;background:#FFFF99">: This email originated from outside of the organization. Do not click links or open attachments unless
 you can confirm the sender and know the content is safe.</span><o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span lang="EN-CA" style="font-size:12.0pt;mso-ligatures:none;mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">Please let me know where I might ask this question or find the answer if this is not the right place.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">In a book I am working on I am writing about how Java deals with memory allocation for the primitive types on a 64 bit CPU. I know the size of primitive variable types such as byte is 1, int is 4, etc. and that the size
 is related to the range of allowable values. From my C/C++ days I learned that the actual amount of RAM used was related to the word size of a CPU so that when a byte is read you are really reading a word. This meant to me that if I had 10 variables of type
 byte, not in an array, it would consume 80 bytes of RAM. From my reading it appears to be the same in Java except for arrays. Is this accurate? For example, an int is 4 bytes but when Java runs on a 64 bit CPU is it really reading and writing 8 bytes? If it
 is, can we say that the 4 bytes of padding is RAM dead space that cannot be used for anything else?
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thank you for your time,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Ken Fogel<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</div>
<br><br><br>Amazon Web Services Development Center Germany GmbH<br>
Tamara-Danz-Str. 13<br>
10243 Berlin<br>
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss<br>
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B<br>
Sitz: Berlin<br>
Ust-ID: DE 365 538 597</body>
</html>