[fpc-devel] threadlocalvar unLOCKed variables

A. Bouchez abouchez at magic.fr
Sat Jan 9 11:12:55 CET 2010

After looking forward in the heap.inc source file supplied with the 2.4.0 software release, I've some remarks:

It seems that small blocks of memory are allocated by thread, using the threadvar freelists declaration... Well..
1. How does it work on multi-thread? E.g. if you allocate a memory block in a thread, and that TWO threads call Reallocmem() at the same time?
2. If I understood well the new heap.inc threading mechanism, the threadlocalgetmem() and such functions I told about is pointless...

Great work done in coding the heap.inc file, indeed... and most classes are created much faster whith this new heap manager.

Another possibility of avoiding asm LOCK, should be to define some new string type (e.g. threadstring), which could also be more aware of string concatenation (allocate more memory at first to avoid most move during realloc). But the dynamic arrays would still use the LOCK.

More information about the fpc-devel mailing list