Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-25701

Bucket::stats: replace manually-managed dynamic array with std::vector

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 5.5.0
    • 5.0.0
    • memcached

    Description

      Context

      In buckets.h (http://src.couchbase.org/source/xref/trunk/kv_engine/daemon/buckets.h#158-161) we maintain an array of statistics for each thread which accesses the bucket.

      The size of the array is determined at runtime based on how many front-end memcached threads have been configured - see http://src.couchbase.org/source/xref/trunk/kv_engine/daemon/memcached.cc#2297

      Currently, the bucket.stats array is implemented using a manually-managed dynamic array - new[] to create it. This is against our current best-practices (and current C++ best practices) - the user must remember to call delete[] to free the memory, if they don't then it cause a memory leak.

      Is is better if we use a standard container class - such as std::vector to manage such resource - this will automatically free the data when it goes out of scope and is hence less error-prone.

      Task

      Change the implementation of bucket.stats to use std::vector instead of a raw pointer / new[]. This will require changing the type definition in buckets.h, changing where it's created / resized. Actual uses of the variable (i.e. reading elements) should stay the same.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            eugen.virtan Eugen Virtan (Inactive)
            drigby Dave Rigby (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty