<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi.
<div class=""><br class="">
</div>
<div class="">The stack representation for virtual threads is currently not as compact as we’d like it to be, and we’re now working on reducing it, possibly drastically. So yes, it is possible that the application will require more heap space, but whether that’s
 the case, or by how much is very much application-dependent, so you’ll need to track the heap usage and allocate heap space appropriately.</div>
<div class=""><br class="">
</div>
<div class="">Virtual threads are lightweight in the sense that they consume much less precious resources than platform threads, and that is why you can have many more of them than platform threads. The resource consumption by platform threads is much more
 constrained than for virtual threads, even in their current state. We expect the heap consumption to be reduced in a future version.</div>
<div class=""><br class="">
</div>
<div class="">— Ron<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 25 Aug 2022, at 03:31, Anindya Bandopadhyay <<a href="mailto:anindyabandopadhyay@gmail.com" class="">anindyabandopadhyay@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi,
<div class="">I am just curious about the heap memory consumption of Virtual Threads.</div>
<div class=""><br class="">
</div>
<div class=""><span id="cid:ii_l78eeyy80"><image.png></span><br class="">
<div class="">
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div class=""><a href="https://gist.githubusercontent.com/andysundar/6401e20fee5674ae47fd94778d37f752/raw/c95905c45cbae47cbb66c3fe46e48f13dcaf19a9/VirtualThreadScaleExample.java" class="">Code Link Here</a><br class="">
</div>
<div dir="ltr" class=""><br class="">
</div>
<div class="">In the above code I am switching the thread factory in line number 10. I was just trying to analyze performance statistics and what I discovered is that virtual thread consumes a significant amount of heap memory (may be due to the continuation
 objects put into heap memory) with respect to platform thread. </div>
<div class=""><br class="">
</div>
<div class="">
<ol class="">
<li class="">Do we need to increase the size of heap memory if we are using virtual thread? <br class="">
</li><li class="">What do you mean by "virtual threads are lightweight" ? </li></ol>
</div>
<div class=""><br class="">
</div>
<div class=""><span id="cid:ii_l78f8xec1"><image.png></span><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Will be eagerly waiting for your reply. </div>
<div class=""><br class="">
</div>
<div dir="ltr" class="">Regards;<br class="">
Anindya Bandopadhyay<br class="">
<a href="http://www.linkedin.com/in/anindyabandopadhyay" target="_blank" class=""><img width="96" height="96" src="https://ci3.googleusercontent.com/mail-sig/AIorK4wc7vkRjiByaujRe_sUyynf3O1RAXCYCZ_SVWU_iA6uy5G3XlVt5h7gI-RWITqVnl9eiHFMQgY" class=""></a><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>