void NMTUsage::walk_thread_stacks() { // If backed by virtual memory, snapping the thread stacks involves walking // them to to figure out how much memory is committed if they are backed by // virtual memory. This needs ot happen before we take the snapshot of the // virtual memory since it will update this information.
if (ThreadStackTracker::track_as_vm()) {
VirtualMemoryTracker::snapshot_thread_stacks();
}
}
void NMTUsage::update_malloc_usage() { // Thread critical needed keep values in sync, total area size // is deducted from mtChunk in the end to give correct values.
ThreadCritical tc; const MallocMemorySnapshot* ms = MallocMemorySummary::as_snapshot();
size_t total_arena_size = 0;
for (int i = 0; i < mt_number_of_types; i++) {
MEMFLAGS flag = NMTUtil::index_to_flag(i); const MallocMemory* mm = ms->by_type(flag);
_malloc_by_type[i] = mm->malloc_size() + mm->arena_size();
total_arena_size += mm->arena_size();
}
// Total malloc size.
_malloc_total = ms->total();
// Adjustment due to mtChunk double counting.
_malloc_by_type[NMTUtil::flag_to_index(mtChunk)] -= total_arena_size;
_malloc_total -= total_arena_size;
// Adjust mtNMT to include malloc overhead.
_malloc_by_type[NMTUtil::flag_to_index(mtNMT)] += ms->malloc_overhead();
}
// Reset total to allow recalculation.
_vm_total.committed = 0;
_vm_total.reserved = 0;
for (int i = 0; i < mt_number_of_types; i++) {
MEMFLAGS flag = NMTUtil::index_to_flag(i); const VirtualMemory* vm = vms->by_type(flag);
void NMTUsage::refresh() {
if (_usage_options.include_malloc) {
update_malloc_usage();
}
if (_usage_options.include_vm) { // Thread stacks only makes sense if virtual memory // is also included. It must be executed before the // over all usage is calculated.
if (_usage_options.update_thread_stacks) {
walk_thread_stacks();
}
update_vm_usage();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.