MCPcopy Create free account
hub / github.com/beefytech/Beef / GetNumericProperty

Method GetNumericProperty

BeefRT/gperftools/src/tcmalloc.cc:641–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639 }
640
641 virtual bool GetNumericProperty(const char* name, size_t* value) {
642 ASSERT(name != NULL);
643
644 if (strcmp(name, "generic.current_allocated_bytes") == 0) {
645 TCMallocStats stats;
646 ExtractStats(&stats, NULL, NULL, NULL);
647 *value = stats.pageheap.system_bytes
648 - stats.thread_bytes
649 - stats.central_bytes
650 - stats.transfer_bytes
651 - stats.pageheap.free_bytes
652 - stats.pageheap.unmapped_bytes;
653 return true;
654 }
655
656 if (strcmp(name, "generic.heap_size") == 0) {
657 TCMallocStats stats;
658 ExtractStats(&stats, NULL, NULL, NULL);
659 *value = stats.pageheap.system_bytes;
660 return true;
661 }
662
663 if (strcmp(name, "tcmalloc.slack_bytes") == 0) {
664 // Kept for backwards compatibility. Now defined externally as:
665 // pageheap_free_bytes + pageheap_unmapped_bytes.
666 SpinLockHolder l(Static::pageheap_lock());
667 PageHeap::Stats stats = Static::pageheap()->stats();
668 *value = stats.free_bytes + stats.unmapped_bytes;
669 return true;
670 }
671
672 if (strcmp(name, "tcmalloc.central_cache_free_bytes") == 0) {
673 TCMallocStats stats;
674 ExtractStats(&stats, NULL, NULL, NULL);
675 *value = stats.central_bytes;
676 return true;
677 }
678
679 if (strcmp(name, "tcmalloc.transfer_cache_free_bytes") == 0) {
680 TCMallocStats stats;
681 ExtractStats(&stats, NULL, NULL, NULL);
682 *value = stats.transfer_bytes;
683 return true;
684 }
685
686 if (strcmp(name, "tcmalloc.thread_cache_free_bytes") == 0) {
687 TCMallocStats stats;
688 ExtractStats(&stats, NULL, NULL, NULL);
689 *value = stats.thread_bytes;
690 return true;
691 }
692
693 if (strcmp(name, "tcmalloc.pageheap_free_bytes") == 0) {
694 SpinLockHolder l(Static::pageheap_lock());
695 *value = Static::pageheap()->stats().free_bytes;
696 return true;
697 }
698

Callers

nothing calls this directly

Calls 1

ExtractStatsFunction · 0.70

Tested by

no test coverage detected