   object pools
  i''m doing some reading on object pools (recycle "dead" objects) to speed up dynamic memory alloc and one thing is bothering me. how or can object pools work with inherited objects? can we have a pool of "base" objects, or must we have a pool of specific objects? 
  specific objects.dirty hacks could be used (using unions) to allow derived objects, but its ugly. ;  You can have several pools, for each different class size. When you allocate memory, you check the size that is required and allocate from the corresponding pool. Similarly when releasing memory. I don't think it ugly at all. Well, it's not the union trick C-Junkie had in mind anyway.   [edited by - civguy on August 4, 2003 6:54:20 AM];  @civguyso only the size matters? ;  Yup. An example implementation using Boost''s pools is here (see FastAllocator.h). ;  muchos graciasone more thingy dough:static void* operator new(size_t size);so when i say:p_smthing = new smthing;the size param is automatically passed?;quote:Original post by original vesoljc  the size param is automatically passed?Yes, new Foo actually does three things in succession* Call the appropriate operator new with sizeof(Foo) as parameter.* Apply Foo''s constructor at the above-returned address* Return the address as a Foo* [ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ][ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ] ;  wicked 