Re: GetMem slow in threads

Marco van de Voort via fpc-pascal <[email protected]>
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <[email protected]>
Op 9-11-2024 om 14:59 schreef Hairy Pixels via fpc-pascal:
>
> The solution would be to be to use a different allocator but because 
> FPC only allows overriding NewInstance per class it would be mean you 
> would need a mutex anyway to control which allocator was used 
> depending on the thread.
>
> Maybe a threadvar could be used to get the allocator for the class 
> type? I haven’t tried but I know there’s a penalty to use that too and 
> it may wipe out of the gains again. I’m not sure what a threadvar is 
> though or how it’s implemented just that the docs say it could be slow.
>
> Any ideas would be appreciated.


Afaik the FPC heapmanager's design is to avoid that lock too frequently 
and have a small per thread heap. This can get frustrated when you do a 
lot of allocating in one thread, and releasing into another.

_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.