tag:blogger.com,1999:blog-4815481734454081491.post8286055155874880817..comments2023-10-24T02:15:03.269-07:00Comments on Minborg's Java Pot: Do Not Let Your Java Objects EscapePer Minborghttp://www.blogger.com/profile/08526963148025854611noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-4815481734454081491.post-16227174231446182252016-01-06T09:12:19.027-08:002016-01-06T09:12:19.027-08:00The GC cleans up the heap and not the stack. The s...The GC cleans up the heap and not the stack. The stack is cleaned up automatically when methods return to their caller whereby the stack pointer is reset to its former value. So GC will clean up objects that ended up on the stack before EA/C2 compilation could be performed. The actual instances (or rather their corresponding representations) live on the stack, there are no referenced objects on the stack in the context of EA optimizations.Per Minborghttps://www.blogger.com/profile/08526963148025854611noreply@blogger.comtag:blogger.com,1999:blog-4815481734454081491.post-6319245587134581742016-01-04T18:03:48.059-08:002016-01-04T18:03:48.059-08:00Very informative.. Pardon my ignorance but reading...Very informative.. Pardon my ignorance but reading "after the System.gc() call cleaned up all our StringBuilders" is the System.gc() really responsible for "cleaning out" StringBuilder instances considering (guessing) they are stack allocated objects? Does the jvm garbage collector clean the stack? Do the StringBuilders ever leave the stack? Are the actual instances really on the stack or just references? Thanks for your educative postsDayonoreply@blogger.comtag:blogger.com,1999:blog-4815481734454081491.post-30641997931704576972015-12-11T09:29:10.574-08:002015-12-11T09:29:10.574-08:00Presumably, if the compiler is using inlining, EA ...Presumably, if the compiler is using inlining, EA might be performed on the aggregate "flattened" code and then the Optional might be EA:ed. This is an interesting question and perhaps i can write a "revisit" post on you question. Per Minborghttps://www.blogger.com/profile/08526963148025854611noreply@blogger.comtag:blogger.com,1999:blog-4815481734454081491.post-11308876096264265242015-12-11T06:25:36.345-08:002015-12-11T06:25:36.345-08:00Curious, if I write a method that directly returns...Curious, if I write a method that directly returns (no tmp var), let's say an Optional (could be something else), and then that Optional is only ever used by the caller, does the optional get EA?Anonymoushttps://www.blogger.com/profile/08185254298048097278noreply@blogger.com