更糟的是,在堆上分配对象时,缓存遗漏还有一个特别讨厌的内存交互。
Worse, a cache miss when allocating an object on the heap has a particularly nasty memory interaction.
新对象是从这个高速缓存的末端分配的,而不必获取堆锁,因此效率非常高。
A new object is allocated from the end of this cache without the need to grab the heap lock, so it is very efficient.
所以,在堆上分配对象,比起在堆栈上分配对象,会带来更多缓存遗漏。
As a result, allocating an object on the heap will likely entail more cache misses than allocating that object on the stack.
应用推荐