safe temp array size that will always prefer TLAB when created

Vitaly Davidovich vitalyd at gmail.com
Tue Jan 20 14:04:57 UTC 2015


See this SO answer for TLAB allocation: http://stackoverflow.com/a/24620205

TLAB allocation doesn't depend on whether the reference is kept in a local
variable or not; perhaps you're thinking of escape analysis, which can
stack allocate objects in some cases.

sent from my phone
On Jan 20, 2015 5:27 AM, "Andy Nuss" <andrew_nuss at yahoo.com> wrote:

> Hi,
>
> I have a ctor for a class that creates a staging char[] buffer, which can
> be smallish, certainly, if necessary a size of 16 suffices for example.
>
> In C++, this would be declared as a simple temporary exact sized array as
> a local stack variable.  I wish to know what is the maximum length I can
> use for my char[] temp buffer, and have a reasonable guarantee that it will
> go into the java TLAB when constructed so that its impact on the heap is
> most like a hypothetical C++ small buffer on the stack.
>
> Further, are there conditions under which hotspot would not locate the
> smallish array in TLAB?  For example, based on whether or not the reference
> to the buffer is saved only in a local variable.  In fact, I wish to
> construct a worker class that in turn constructs the small temp char[],
> saves it in a member, and the worker is used only in a loop and does not
> escape the function that creates it, so the worker reference is never kept
> anywhere but on the stack.
>
> Andy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150120/8e6883dd/attachment.html>


More information about the hotspot-compiler-dev mailing list