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 */ 24 25 #ifndef SHARE_VM_SERVICES_MEM_TRACKER_HPP 26 #define SHARE_VM_SERVICES_MEM_TRACKER_HPP 27 28 #include "memory/allocation.hpp" 29 #include "runtime/globals.hpp" 30 #include "runtime/mutex.hpp" 31 #include "runtime/os.hpp" 32 #include "runtime/thread.hpp" 33 #include "services/memPtr.hpp" 34 #include "services/memRecorder.hpp" 35 #include "services/memSnapshot.hpp" 36 #include "services/memTrackWorker.hpp" 37 38 #ifdef SOLARIS 39 #include "thread_solaris.inline.hpp" 40 #endif 41 42 #ifdef _DEBUG 43 #define DEBUG_CALLER_PC os::get_caller_pc(3) 44 #else 45 #define DEBUG_CALLER_PC 0 46 #endif 47 385 static volatile jint _pooled_recorder_count; 386 387 388 // worker thread to merge pending recorders into snapshot 389 static MemTrackWorker* _worker_thread; 390 391 // how many safepoints we skipped without entering sync point 392 static int _sync_point_skip_count; 393 394 // if the tracker is properly intialized 395 static bool _is_tracker_ready; 396 // tracking level (off, summary and detail) 397 static enum NMTLevel _tracking_level; 398 399 // current nmt state 400 static volatile enum NMTStates _state; 401 // the reason for shutting down nmt 402 static enum ShutdownReason _reason; 403 }; 404 405 #endif // SHARE_VM_SERVICES_MEM_TRACKER_HPP | 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 */ 24 25 #ifndef SHARE_VM_SERVICES_MEM_TRACKER_HPP 26 #define SHARE_VM_SERVICES_MEM_TRACKER_HPP 27 28 #include "utilities/macros.hpp" 29 30 #if !INCLUDE_NMT 31 32 #include "utilities/ostream.hpp" 33 34 class BaselineOutputer : public StackObj { 35 36 }; 37 38 class BaselineTTYOutputer : public BaselineOutputer { 39 public: 40 BaselineTTYOutputer(outputStream* st) { } 41 }; 42 43 class MemTracker: AllStatic { 44 public: 45 enum ShutdownReason { 46 NMT_shutdown_none, // no shutdown requested 47 NMT_shutdown_user, // user requested shutdown 48 NMT_normal, // normal shutdown, process exit 49 NMT_out_of_memory, // shutdown due to out of memory 50 NMT_initialization, // shutdown due to initialization failure 51 NMT_use_malloc_only, // can not combine NMT with UseMallocOnly flag 52 NMT_error_reporting, // shutdown by vmError::report_and_die() 53 NMT_out_of_generation, // running out of generation queue 54 NMT_sequence_overflow // overflow the sequence number 55 }; 56 57 58 public: 59 static inline void init_tracking_options(const char* option_line) { } 60 static inline bool is_on() { return false; } 61 static const char* reason() { return "Native memory tracking is not implemented"; } 62 static inline bool can_walk_stack() { return false; } 63 64 static inline void bootstrap_single_thread() { } 65 static inline void bootstrap_multi_thread() { } 66 static inline void start() { } 67 68 static inline void record_malloc(address addr, size_t size, MEMFLAGS flags, 69 address pc = 0, Thread* thread = NULL) { } 70 static inline void record_free(address addr, MEMFLAGS flags, Thread* thread = NULL) { } 71 static inline void record_realloc(address old_addr, address new_addr, size_t size, 72 MEMFLAGS flags, address pc = 0, Thread* thread = NULL) { } 73 static inline void record_arena_size(address addr, size_t size) { } 74 static inline void record_virtual_memory_reserve(address addr, size_t size, 75 address pc = 0, Thread* thread = NULL) { } 76 static inline void record_virtual_memory_commit(address addr, size_t size, 77 address pc = 0, Thread* thread = NULL) { } 78 static inline void record_virtual_memory_uncommit(address addr, size_t size, 79 Thread* thread = NULL) { } 80 static inline void record_virtual_memory_release(address addr, size_t size, 81 Thread* thread = NULL) { } 82 static inline void record_virtual_memory_type(address base, MEMFLAGS flags, 83 Thread* thread = NULL) { } 84 static inline bool baseline() { return false; } 85 static inline bool has_baseline() { return false; } 86 87 static void shutdown(ShutdownReason reason) { } 88 static inline bool shutdown_in_progress() { } 89 static bool print_memory_usage(BaselineOutputer& out, size_t unit, 90 bool summary_only = true) { } 91 static bool compare_memory_usage(BaselineOutputer& out, size_t unit, 92 bool summary_only = true) { } 93 94 static inline void sync() { } 95 static inline void thread_exiting(JavaThread* thread) { } 96 97 }; 98 99 100 #else // !INCLUDE_NMT 101 102 #include "memory/allocation.hpp" 103 #include "runtime/globals.hpp" 104 #include "runtime/mutex.hpp" 105 #include "runtime/os.hpp" 106 #include "runtime/thread.hpp" 107 #include "services/memPtr.hpp" 108 #include "services/memRecorder.hpp" 109 #include "services/memSnapshot.hpp" 110 #include "services/memTrackWorker.hpp" 111 112 #ifdef SOLARIS 113 #include "thread_solaris.inline.hpp" 114 #endif 115 116 #ifdef _DEBUG 117 #define DEBUG_CALLER_PC os::get_caller_pc(3) 118 #else 119 #define DEBUG_CALLER_PC 0 120 #endif 121 459 static volatile jint _pooled_recorder_count; 460 461 462 // worker thread to merge pending recorders into snapshot 463 static MemTrackWorker* _worker_thread; 464 465 // how many safepoints we skipped without entering sync point 466 static int _sync_point_skip_count; 467 468 // if the tracker is properly intialized 469 static bool _is_tracker_ready; 470 // tracking level (off, summary and detail) 471 static enum NMTLevel _tracking_level; 472 473 // current nmt state 474 static volatile enum NMTStates _state; 475 // the reason for shutting down nmt 476 static enum ShutdownReason _reason; 477 }; 478 479 #endif // !INCLUDE_NMT 480 481 #endif // SHARE_VM_SERVICES_MEM_TRACKER_HPP |