List:Internals« Previous MessageNext Message »
From:MARK CALLAGHAN Date:February 27 2009 2:06pm
Subject:Re: [Drizzle-discuss] Removing Array custom vector allocation for
semi-join subqueries
View as plain text  
On Fri, Feb 27, 2009 at 2:11 AM, Konstantin Osipov <kostja@stripped> wrote:
> * Monty Taylor <mordred@stripped> [09/02/27 10:21]:
>> > My C++ skills have faded given what I work on. What does C++ have that
>> > is similar to mem_root? That is, I want an allocator to be used with a
>> > variety of STL classes for which I will deallocate everyting all at
>> > once but at some random point in the future. And since I don't want to
>> > have to retain handles to everything that has been allocated, I prefer
>> > to invoke deallocate on the allocator rather than all of the objects
>> > that have been allocated from it.
>>
>> No. C++ does not have a thing that behaves exactly like mem_root does.
>> You could build one, but it would be (and is) a bad idea, because things
>> you're allocating in C++ are objects, and you need to run destructors on
>> them, and because then you'd be trying to program idiomatic C in C++.
>
> Memory life cycle != object life cycle. Mark, you need to look at
> STL allocators.
>

Extensive knowledge of C++/STL isn't much use when working on
non-drizzled MySQL so I might defer looking. I have had fun using STL
with code added to MySQL at times (-fno-implict-templates, MySQL
headers don't like STL headers). My favorite problem is when I added
<string> to handler.cc and then sizeof(ha_archive) was different
between handler.o and ha_archive.o.

In the MySQL server I want memory and object life cycles to be the
same (or for this not to matter) for almost all objects and for
resource management to be done explicitly via Release methods, not
from code run in destructors. The only resource most objects should be
managing is memory allocated for fields and contained objects -- so
pushing responsibility for deallocation to something like mem_root
should work. Only a few classes should deal with things like locks or
file descriptors.

And for something as critical as memory, mem_root has some great
properties. I can easily count bytes currently allocated in MEM_ROOT
instances and leaks should be less likely. I have had fun with this
recently as well
* http://bugs.mysql.com/bug.php?id=43237
* http://bugs.mysql.com/bug.php?id=27732

-- 
Mark Callaghan
mdcallag@stripped
Thread
Removing Array custom vector allocation for semi-join subqueriesJay Pipes26 Feb
  • Re: Removing Array custom vector allocation for semi-join subqueriesKonstantin Osipov26 Feb
    • Re: Removing Array custom vector allocation for semi-join subqueriesJay Pipes26 Feb
  • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesKonstantin Osipov26 Feb
    • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJay Pipes26 Feb
Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesBrian Aker26 Feb
  • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMonty Taylor27 Feb
    • Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesMARK CALLAGHAN27 Feb
      • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMonty Taylor27 Feb
        • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesKonstantin Osipov27 Feb
          • Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesMARK CALLAGHAN27 Feb
        • Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesMARK CALLAGHAN27 Feb
          • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJim Starkey27 Feb
    • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMichael Widenius2 Mar
      • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJay Pipes2 Mar
      • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesJim Starkey2 Mar
        • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesKonstantin Osipov2 Mar
        • Re: [Drizzle-discuss] Removing Array custom vector allocation forsemi-join subqueriesMichael Widenius5 Mar
Re: [Drizzle-discuss] Removing Array custom vector allocation for semi-join subqueriesBrian Aker26 Feb