https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124553

            Bug ID: 124553
           Summary: -fmem-stats tracking of vec<> does not track ::release
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: internal-improvement
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

We have

/* Allocator type for heap vectors.  */
struct va_heap
{
  /* Heap vectors are frequently regular instances, so use the vl_ptr
     layout for them.  */
  typedef vl_ptr default_layout; 

  template<typename T>
  static void reserve (vec<T, va_heap, vl_embed> *&, unsigned, bool
                       CXX_MEM_STAT_INFO);

  template<typename T>
  static void release (vec<T, va_heap, vl_embed> *&);

and

template<typename T>
void
va_heap::release (vec<T, va_heap, vl_embed> *&v)
{
  size_t elt_size = sizeof (T);
  if (v == NULL)
    return;

  if (!std::is_trivially_destructible <T>::value)
    vec_destruct (v->address (), v->length ());

  if (GATHER_STATISTICS)
    v->m_vecpfx.release_overhead (v, elt_size * v->allocated (),
                                  v->allocated (), true);

I think this causes v.release () to be not properly tracked and misreports
like

tree-ssa-sccvn.cc:4399 (vn_reference_insert)             48        24M:45.7%   
   24M    680613: 4.0%       528k       529k

leaking of 24M memory?

Reply via email to