You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by aniket ray <an...@gmail.com> on 2011/04/26 18:53:21 UTC

Sanctity of TSMalloc within plugins

Hi,

I wanted to know whether new/delete, malloc/free combos can be used in
ATS Plugins. Is it necessary to use the TSmalloc/TSfree combo?
Several libraries use malloc/free. Can they be safely used within ATS?

On a related note, is STL safe within a plugin's code?

Thanks,
aniket

Re: Sanctity of TSMalloc within plugins

Posted by Leif Hedstrom <zw...@apache.org>.
Technically, you can use whatever you like, but we recommend TSmalloc because we plan on making improvements here going forward post 3.0 release.

STL is certainly fine to use, particularly for read-only containers (I use STL containers in my plugins to store configuration structures, which are created at startup). If you need to write to a container while processing request, you are responsible for making it thread safe (e.g. locks or atomically swap pointers etc.). 

-- leif

Sent from my iPad

On Apr 26, 2011, at 10:53 AM, aniket ray <an...@gmail.com> wrote:

> Hi,
> 
> I wanted to know whether new/delete, malloc/free combos can be used in
> ATS Plugins. Is it necessary to use the TSmalloc/TSfree combo?
> Several libraries use malloc/free. Can they be safely used within ATS?
> 
> On a related note, is STL safe within a plugin's code?
> 
> Thanks,
> aniket