src/share/vm/services/memTrackWorker.hpp

Thu, 28 Jun 2012 17:03:16 -0400

author
zgu
date
Thu, 28 Jun 2012 17:03:16 -0400
changeset 3900
d2a62e0f25eb
child 3935
7e5976e66c62
permissions
-rw-r--r--

6995781: Native Memory Tracking (Phase 1)
7151532: DCmd for hotspot native memory tracking
Summary: Implementation of native memory tracking phase 1, which tracks VM native memory usage, and related DCmd
Reviewed-by: acorn, coleenp, fparain

     1 /*
     2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP
    26 #define SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP
    28 #include "memory/allocation.hpp"
    29 #include "runtime/thread.hpp"
    30 #include "services/memRecorder.hpp"
    32 // Maximum MAX_GENERATIONS generation data can be tracked.
    33 #define MAX_GENERATIONS  512
    36 class MemTrackWorker : public NamedThread {
    37  private:
    38   // circular buffer. This buffer contains recorders to be merged into global
    39   // snaphsot.
    40   // Each slot holds a linked list of memory recorders, that contains one
    41   // generation of memory data.
    42   MemRecorder*  _gen[MAX_GENERATIONS];
    43   int           _head, _tail; // head and tail pointers to above circular buffer
    45   bool          _has_error;
    47  public:
    48   MemTrackWorker();
    49   ~MemTrackWorker();
    50   _NOINLINE_ void* operator new(size_t size);
    51   _NOINLINE_ void* operator new(size_t size, const std::nothrow_t& nothrow_constant);
    53   void start();
    54   void run();
    56   inline bool has_error() const { return _has_error; }
    58   // task at synchronization point
    59   void at_sync_point(MemRecorder* pending_recorders);
    61   // for debugging purpose, they are not thread safe.
    62   NOT_PRODUCT(static int count_recorder(const MemRecorder* head);)
    63   NOT_PRODUCT(int count_pending_recorders() const;)
    65   NOT_PRODUCT(int _sync_point_count;)
    66   NOT_PRODUCT(int _merge_count;)
    67   NOT_PRODUCT(int _last_gen_in_use;)
    69   inline int generations_in_use() const {
    70     return (_tail <= _head ? (_head - _tail + 1) : (MAX_GENERATIONS - (_tail - _head) + 1));
    71   }
    72 };
    74 #endif // SHARE_VM_SERVICES_MEM_TRACK_WORKER_HPP

mercurial