List:Internals« Previous MessageNext Message »
From:Mats Kindahl Date:June 14 2005 11:56am
Subject:bk commit into 5.1 tree (mkindahl:1.1959)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mkindahl. When mkindahl does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1959 05/06/14 11:56:40 mkindahl@stripped +3 -0
  WL#2325: Removing memory leak from table_mapping by keeping track of allocated
  chunks (and deleting them in the destructor).

  BitKeeper/etc/logging_ok
    1.304 05/06/14 11:55:14 mkindahl@stripped +1 -0
    Logging to logging@stripped accepted

  sql/rpl_tblmap.cc
    1.13 05/06/14 11:54:08 mkindahl@stripped +6 -11
    Removing memory leak from table_mapping by keeping track of allocated chunks.

  sql/rpl_tblmap.h
    1.7 05/06/14 11:53:53 mkindahl@stripped +2 -1
    Removing memory leak from table_mapping by keeping track of allocated chunks.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	mkindahl
# Host:	bk-internal.mysql.com
# Root:	/data0/bk/mysql-5.1-wl2325

--- 1.303/BitKeeper/etc/logging_ok	2005-06-08 16:53:06 +02:00
+++ 1.304/BitKeeper/etc/logging_ok	2005-06-14 11:55:14 +02:00
@@ -158,6 +158,7 @@
 mikael@stripped
 mikron@stripped
 mikron@stripped
+mkindahl@stripped
 mleich@stripped
 mmatthew@markslaptop.
 monty@stripped

--- 1.12/sql/rpl_tblmap.cc	2005-06-13 10:05:47 +02:00
+++ 1.13/sql/rpl_tblmap.cc	2005-06-14 11:54:08 +02:00
@@ -19,16 +19,9 @@
 table_mapping::
 ~table_mapping()
 {
+  while (entry *chunk = static_cast<entry*>(m_chunks.pop()))
+    delete [] chunk;
   hash_free(&m_table_ids);
-  entry *ptr = m_free;
-  while (ptr) {
-      // The memory is allocated in chunks of TABLE_ID_CHUNK entries,
-      // so we find the last entry in the chunk and follow the next
-      // pointer.
-      entry *tmp = ptr[TABLE_ID_CHUNK - 1].next;
-      my_free(reinterpret_cast<char*>(ptr), MYF(0));
-      ptr = tmp;
-  }
 }
 
 st_table* table_mapping::
@@ -52,11 +45,13 @@
 int table_mapping::
 expand()
 {
-  entry *tmp= (entry *)my_malloc(TABLE_ID_CHUNK*sizeof(entry),
-				 MYF(MY_WME));
+  entry *tmp= new entry[TABLE_ID_CHUNK];
   if (tmp == NULL)
     return ERR_MEMORY_ALLOCATION; // Memory allocation failed
 
+  m_chunks.push_front(tmp);
+
+  // Find the end of the array of entries.
   entry *e_end= tmp+TABLE_ID_CHUNK-1;
   for (entry *e= tmp; e < e_end; e++)
     e->next= e+1;

--- 1.6/sql/rpl_tblmap.h	2005-05-24 15:02:48 +02:00
+++ 1.7/sql/rpl_tblmap.h	2005-06-14 11:53:53 +02:00
@@ -42,6 +42,7 @@
   ulong     count() const { return m_table_ids.records; }
 
 private:
+  // This is a POD (Plain Old Data).  Keep it that way.
   struct entry { 
     ulong table_id;
     union {
@@ -58,7 +59,7 @@
   }
   int expand();
 
-  List<entry> m_array;
+  List<entry> m_chunks;         // List of allocated chunks
   entry *m_free;
 
   HASH m_table_ids;
Thread
bk commit into 5.1 tree (mkindahl:1.1959)Mats Kindahl14 Jun