Comments on: Do Not Let Your Java Objects Escape https://speedment.com/do-not-let-your-java-objects-escape/ Build Fast Java Applications for the Fastest Business Performance Fri, 01 May 2020 05:21:37 +0000 hourly 1 https://wordpress.org/?v=5.1.1 By: Per Minborg https://speedment.com/do-not-let-your-java-objects-escape/#comment-145 Wed, 06 Jan 2016 17:12:19 +0000 https://speedment.com/do-not-let-your-java-objects-escape/#comment-145 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.

]]>
By: Dayo https://speedment.com/do-not-let-your-java-objects-escape/#comment-147 Tue, 05 Jan 2016 02:03:48 +0000 https://speedment.com/do-not-let-your-java-objects-escape/#comment-147 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 posts

]]>
By: Per Minborg https://speedment.com/do-not-let-your-java-objects-escape/#comment-155 Fri, 11 Dec 2015 17:29:10 +0000 https://speedment.com/do-not-let-your-java-objects-escape/#comment-155 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.

]]>
By: Unknown https://speedment.com/do-not-let-your-java-objects-escape/#comment-156 Fri, 11 Dec 2015 14:25:36 +0000 https://speedment.com/do-not-let-your-java-objects-escape/#comment-156 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?

]]>