本文整理汇总了C++中CollectedHeap::capacity方法的典型用法代码示例。如果您正苦于以下问题:C++ CollectedHeap::capacity方法的具体用法?C++ CollectedHeap::capacity怎么用?C++ CollectedHeap::capacity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CollectedHeap
的用法示例。
在下文中一共展示了CollectedHeap::capacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log_stop
inline void GCTraceTimeImpl::log_stop(jlong start_counter, jlong stop_counter) {
double duration_in_ms = TimeHelper::counter_to_millis(stop_counter - start_counter);
double start_time_in_secs = TimeHelper::counter_to_seconds(start_counter);
double stop_time_in_secs = TimeHelper::counter_to_seconds(stop_counter);
LogStream out(_out_stop);
out.print("%s", _title);
if (_gc_cause != GCCause::_no_gc) {
out.print(" (%s)", GCCause::to_string(_gc_cause));
}
if (_heap_usage_before != SIZE_MAX) {
CollectedHeap* heap = Universe::heap();
size_t used_before_m = _heap_usage_before / M;
size_t used_m = heap->used() / M;
size_t capacity_m = heap->capacity() / M;
out.print(" " LOG_STOP_HEAP_FORMAT, used_before_m, used_m, capacity_m);
}
out.print_cr(" " LOG_STOP_TIME_FORMAT, start_time_in_secs, stop_time_in_secs, duration_in_ms);
}
示例2: task
void SharedUserData::task(){
#ifdef AZ_PROXIED
// Static variables store peak values seen during the life of the run.
static volatile sud_jvm_heap_rev1_t peak_jvm_heap;
static sud_io_rev1_t io_stats;
static volatile bool initialized = false;
if (!initialized) {
memset ((void*)(&peak_jvm_heap), 0, sizeof(peak_jvm_heap));
initialized = true;
}
if (SafepointSynchronize::is_at_safepoint()) return;
CollectedHeap *heap = Universe::heap();
if (!heap) return;
size_t l = heap->last_gc_live_bytes();
size_t u=heap->used();
size_t c = heap->capacity();
size_t m = heap->max_capacity();
size_t pu = heap->permanent_used();
size_t pc = heap->permanent_capacity();
// Make sure that the numbers make sense when graphing.
c = (u > c) ? u : c;
m = (c > m) ? c : m;
pc = (pu > pc) ? pu : pc;
sud_jvm_heap_rev1_t jvm_heap;
memset(&jvm_heap, 0, sizeof(jvm_heap));
jvm_heap.revision = SUD_JVM_HEAP_REVISION;
switch (heap->kind()) {
case CollectedHeap::GenCollectedHeap: strcpy(jvm_heap.name, "GenCollectedHeap"); break;
case CollectedHeap::ParallelScavengeHeap: strcpy(jvm_heap.name, "ParallelScavengeHeap"); break;
case CollectedHeap::PauselessHeap: strcpy(jvm_heap.name, "PauselessHeap"); break;
default: strcpy(jvm_heap.name, "");
}
if (heap->supports_tlab_allocation()) jvm_heap.flags |= SUD_JVM_HEAP_FLAG_TLAB_ALLOCATION;
if (heap->supports_inline_contig_alloc()) jvm_heap.flags |= SUD_JVM_HEAP_FLAG_INLINE_CONTIG_ALLOC;
uint64_t now = (uint64_t) os::javaTimeMillis();
jvm_heap.timestamp_ms = now;
jvm_heap.live_bytes = l;
jvm_heap.used_bytes = u;
jvm_heap.capacity_bytes = c;
jvm_heap.max_capacity_bytes = m;
jvm_heap.permanent_used_bytes = pu;
jvm_heap.permanent_capacity_bytes = pc;
jvm_heap.total_collections = heap->total_collections();
libos::AccountInfo ai;
az_allocid_t allocid = process_get_allocationid();
sys_return_t ret = ai.inspectProcess (allocid);
if (ret == SYSERR_NONE) {
// Copy memory_accounting information into the sud structure.
// Take care not to overflow the accounts past the maximum storable.
const account_info_t *account_info = ai.getAccountInfo();
uint64_t count =
(account_info->ac_count < SUD_MAX_ACCOUNTS) ?
account_info->ac_count :
SUD_MAX_ACCOUNTS;
jvm_heap.account_info.ac_count = count;
for (uint64_t i = 0; i < count; i++) {
jvm_heap.account_info.ac_array[i] = account_info->ac_array[i];
}
}
else {
warning("Failed to inspect memory accounting info (%d)",ret);
}
#define UPDATE_PEAK(struct_member,value) \
if (peak_jvm_heap.peak_ ## struct_member ## _bytes < value) { \
peak_jvm_heap.peak_ ## struct_member ## _bytes = value; \
peak_jvm_heap.peak_ ## struct_member ## _timestamp_ms = now; \
} \
jvm_heap.peak_ ## struct_member ## _bytes = peak_jvm_heap.peak_ ## struct_member ## _bytes; \
jvm_heap.peak_ ## struct_member ## _timestamp_ms = peak_jvm_heap.peak_ ## struct_member ## _timestamp_ms;
UPDATE_PEAK (live,l);
UPDATE_PEAK (used,u);
UPDATE_PEAK (capacity,c);
UPDATE_PEAK (max_capacity,m);
UPDATE_PEAK (permanent_used,pu);
UPDATE_PEAK (permanent_capacity,pc);
UPDATE_PEAK (allocated,ai.getAllocatedBytes());
UPDATE_PEAK (funded,ai.getFundedBytes());
UPDATE_PEAK (overdraft,ai.getOverdraftBytes());
UPDATE_PEAK (footprint,ai.getFootprintBytes());
UPDATE_PEAK (committed,ai.getCommittedBytes());
UPDATE_PEAK (grant,ai.getGrantBytes());
UPDATE_PEAK (allocated_from_committed,ai.getAllocatedFromCommittedBytes());
UPDATE_PEAK (default_allocated,ai.getDefaultAllocatedBytes());
UPDATE_PEAK (default_committed,ai.getDefaultCommittedBytes());
UPDATE_PEAK (default_footprint,ai.getDefaultFootprintBytes());
UPDATE_PEAK (default_grant,ai.getDefaultGrantBytes());
UPDATE_PEAK (heap_allocated,ai.getHeapAllocatedBytes());
//.........这里部分代码省略.........