Teg <[EMAIL PROTECTED]> wrote:
> Hello drh,
> 
> Could you perhaps give us the rational for using TLS? How is it that
> TLS is needed on cases where you run out of memory? 

It makes the code smaller and faster to set a flag when
malloc fails, rather than trying to test for the failure
all the way back up the stack.

The flag used to be a global variable.  But that was
causing problems for embedded device manufacturers.
Specifically, embedded devices run out of memory quite
often - a malloc() failure is routine.  It is not
acceptable to shut down the whole process just because malloc
failed.  But if the failure flag is in a global variable,
there is no way to know which thread took the failure
and hence no way to recover gracefully.  Everything
has to be stopped and restarted.  By moving the
malloc failure flag into TLS, we can recover gracefully
from OOM without impacting other threads at all.

TLS is also used to support new features of 3.3.0:
Share caches and memory management.  Both are off by
default.  But if you want to use them you will need
TLS.
--
D. Richard Hipp <[EMAIL PROTECTED]>

Reply via email to