<div dir="auto">Would making a wrapper around the allocated object make a difference? (And clear the reference in the wrapper after the right line)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 7 Nov 2022, 11:55 Alan Bateman, <<a href="mailto:Alan.Bateman@oracle.com" target="_blank" rel="noreferrer">Alan.Bateman@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 07/11/2022 07:29, Sam Pullara wrote:<br>
> I am kind of annoyed this doesn't solve the problem (scoping the <br>
> allocation):<br>
<br>
You may have reduced the scope of bigBuffer in the source code but the <br>
code generated by the javac compiler will be the same, meaning the <br>
method will have the same number of locals as before.<br>
<br>
For Arnaud's test, the local for bigBuffer will be live when it is <br>
running in the interpreter so freezing the stack during slowIO will keep <br>
it reachable.  It should be different once the code is warmed and <br>
compiled by C2 but it may be that the observations with VisualVM are <br>
done before it is compiled at run-time.<br>
<br>
-Alan<br>
</blockquote></div>