Java nonblocking memory allocation

后端 未结 3 679
野趣味
野趣味 2021-02-01 09:00

I read somewhere that java can allocate memory for objects in about 12 machine instructions. It\'s quite impressive for me. As far as I understand one of tricks JVM using is pre

3条回答
  •  天涯浪人
    2021-02-01 09:44

    The JVM pre-allocates an area of memory for each thread (TLA or Thread Local Area). When a thread needs to allocate memory, it will use "Bump the pointer allocation" within that area. (If the "free pointer" points to adress 10, and the object to be allocated is size 50, then we just bump the free pointer to 60, and tell the thread that it can use the memory between 10 and 59 for the object).

提交回复
热议问题