<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,6 @@
 
+v0.16.2. Fix memory leak.
+
 v0.16.1. Use seeded random. Fix realloc bug on Linux.
 
 v0.16. Build properly on OS X Snow Leopard.</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -38,9 +38,7 @@ if !ENV[&quot;EXTERNAL_LIB&quot;]
 
       Dir.chdir(BUNDLE_PATH) do
         
-        cflags = &quot;-fPIC&quot;
-        cxxflags = cflags
-        ldflags = &quot;-fPIC&quot;
+        cxxflags = cflags = ldflags = &quot;-fPIC&quot;
         extraconf = ''
         
         # again... is there a better way to do this?
@@ -50,6 +48,12 @@ if !ENV[&quot;EXTERNAL_LIB&quot;]
           ldflags = &quot;#{ldflags} #{archflags}&quot;
           extraconf = '--enable-dtrace --disable-dependency-tracking'
         end
+                
+        if ENV['DEBUG']
+          puts &quot;Setting debug flags for libmemcached.&quot;
+          cflags &lt;&lt; &quot; -O0 -ggdb -DHAVE_DEBUG&quot;
+          extraconf &lt;&lt; &quot; --enable-debug&quot;
+        end
         
         puts(cmd = &quot;env CFLAGS='#{cflags}' LDFLAGS='#{ldflags}' ./configure --prefix=#{HERE} --without-memcached --disable-shared --disable-utils #{extraconf} 2&gt;&amp;1&quot;)
         raise &quot;'#{cmd}' failed&quot; unless system(cmd)
@@ -58,7 +62,10 @@ if !ENV[&quot;EXTERNAL_LIB&quot;]
         puts(cmd = &quot;make install || true 2&gt;&amp;1&quot;)
         raise &quot;'#{cmd}' failed&quot; unless system(cmd)
       end
-      system(&quot;rm -rf #{BUNDLE_PATH}&quot;) unless ENV['DEV']
+
+      unless ENV['DEBUG'] or ENV['DEV']
+        system(&quot;rm -rf #{BUNDLE_PATH}&quot;)
+      end
     end
   end
   
@@ -70,6 +77,15 @@ if !ENV[&quot;EXTERNAL_LIB&quot;]
   $LIBS &lt;&lt; &quot; -lmemcached_gem&quot;
 end
 
+$CFLAGS.gsub! /-O\d/, ''
+
+if ENV['DEBUG']
+  puts &quot;Setting debug flags for gem.&quot;
+  $CFLAGS &lt;&lt; &quot; -O0 -ggdb -DHAVE_DEBUG&quot;
+else
+  $CFLAGS &lt;&lt; &quot; -O3&quot;
+end
+
 if DARWIN
   $CFLAGS.gsub! /-arch \S+/, ''
   $CFLAGS &lt;&lt; &quot; #{archflags}&quot;
@@ -83,13 +99,4 @@ if ENV['SWIG']
   raise &quot;'#{cmd}' failed&quot; unless system(cmd)
 end
 
-$CFLAGS.gsub! /-O\d/, ''
-
-if ENV['DEBUG']
-  puts &quot;Setting debug flags.&quot;
-  $CFLAGS &lt;&lt; &quot; -O0 -ggdb -DHAVE_DEBUG&quot;
-else
-  $CFLAGS &lt;&lt; &quot; -O3&quot;
-end
-
 create_makefile 'rlibmemcached'</diff>
      <filename>ext/extconf.rb</filename>
    </modified>
    <modified>
      <diff>@@ -137,9 +137,12 @@ Please note that when pipelining is enabled, setter and deleter methods do not r
   # object.
   #
   def clone
-    memcached = super
-    memcached.instance_variable_set('@struct', Lib.memcached_clone(nil, @struct))
-    memcached
+    # FIXME Memory leak
+    # memcached = super
+    # struct = Lib.memcached_clone(nil, @struct)
+    # memcached.instance_variable_set('@struct', struct)
+    # memcached
+    self.class.new(servers, options)
   end
 
   # Reset the state of the libmemcached struct. This is useful for changing the server list at runtime.</diff>
      <filename>lib/memcached/memcached.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ class Worker
     @method = method_name || 'mixed'
     @i = (iterations || 10000).to_i
     
-    puts &quot;Running #{@method.inspect} test for #{@i} loops.&quot;
+    puts &quot;*** Running #{@method.inspect} test for #{@i} loops. ***&quot;
 
     @key1 = &quot;key1-&quot;*8  
     @key2 = &quot;key2-&quot;*8  
@@ -104,6 +104,10 @@ class Worker
         @i.times do
           cache = @cache.clone
         end
+      when &quot;reset&quot;
+        @i.times do
+          @cache.reset
+        end
       when &quot;servers&quot;
         @i.times do
           @cache.servers
@@ -112,9 +116,18 @@ class Worker
         raise &quot;No such method&quot;
     end
     
-    GC.start
+    puts &quot;*** Garbage collect. ***&quot;
+    10.times do       
+      GC.start
+      sleep 0.1
+    end
+
+    sts, clients = 0, 0
+    ObjectSpace.each_object(Memcached) { clients += 1 }
+    ObjectSpace.each_object(Rlibmemcached::MemcachedSt) { sts += 1 }  
+    puts &quot;*** Structs: #{sts} ***&quot;
+    puts &quot;*** Clients: #{clients} ***&quot;
   end  
-  
 end
 
 Worker.new(ENV['METHOD'], ENV['LOOPS']).work</diff>
      <filename>test/profile/valgrind.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2c18ee7cc31b20b4df9ec8c6941dfbc6389f676d</id>
    </parent>
  </parents>
  <author>
    <name>Evan Weaver</name>
    <email>eweaver@twitter.com</email>
  </author>
  <url>http://github.com/chriseppstein/memcached/commit/1523ed860a4a620675f63c64a56654f21b728142</url>
  <id>1523ed860a4a620675f63c64a56654f21b728142</id>
  <committed-date>2009-09-02T21:34:00-07:00</committed-date>
  <authored-date>2009-09-02T21:33:39-07:00</authored-date>
  <message>Fix clone memory leak.</message>
  <tree>2606190544497ef10d31c0b960442acc29d21388</tree>
  <committer>
    <name>Evan Weaver</name>
    <email>eweaver@twitter.com</email>
  </committer>
</commit>
