[sldev] performance with LLPointer

Bryan O'Sullivan bos at lindenlab.com
Fri Jul 13 14:08:00 PDT 2007


Nicholaz Beresford wrote:

> Does anyone know if using LLPointers over regular C++
> pointers will cause performance issues?

It can, because of the need to constantly update refcounts.  That 
imposes a small compute overhead and has something of a cache impact. 
How measurable is hard to say, but I wouldn't want to be fiddling with 
LLPointers in a place I knew was an inner loop.

At least sometimes, you can amortise this cost by using an LLPointer& 
instead of a plain LLPointer.

However, the more scary potential problem is of objects being kept alive 
by references when they would not otherwise be.  There are two ways this 
can happen: one is circular references, which are extremely hard to 
track down in the code.  The other is objects with LLPointer members not 
nulling them out when they're really done with them, thus keeping the 
pointed-to objects alive.

So be very, very careful in this area.  It's a fertile source of bugs, 
including some recent killer memory leaks from the past few months.

	<b


More information about the SLDev mailing list