本文整理汇总了C++中GC_get_heap_size函数的典型用法代码示例。如果您正苦于以下问题:C++ GC_get_heap_size函数的具体用法?C++ GC_get_heap_size怎么用?C++ GC_get_heap_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GC_get_heap_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitBags
void InitBags(UInt initial_size,
Bag * stack_bottom,
UInt stack_align)
{
UInt i; /* loop variable */
/* install the marking functions */
for (i = 0; i < NUM_TYPES; i++) {
TabMarkTypeBags[i] = -1;
}
#ifndef DISABLE_GC
#ifdef HPCGAP
if (!getenv("GC_MARKERS")) {
/* The Boehm GC does not have an API to set the number of
* markers for the parallel mark and sweep implementation,
* so we use the documented environment variable GC_MARKERS
* instead. However, we do not override it if it's already
* set.
*/
static char marker_env_str[32];
unsigned num_markers = 2;
if (!SyNumGCThreads)
SyNumGCThreads = SyNumProcessors;
if (SyNumGCThreads) {
if (SyNumGCThreads <= MAX_GC_THREADS)
num_markers = (unsigned)SyNumProcessors;
else
num_markers = MAX_GC_THREADS;
}
sprintf(marker_env_str, "GC_MARKERS=%u", num_markers);
putenv(marker_env_str);
}
#endif
GC_set_all_interior_pointers(0);
GC_init();
GC_set_free_space_divisor(1);
TLAllocatorInit();
GC_register_displacement(0);
GC_register_displacement(sizeof(BagHeader));
initial_size *= 1024;
if (GC_get_heap_size() < initial_size)
GC_expand_hp(initial_size - GC_get_heap_size());
if (SyStorKill)
GC_set_max_heap_size(SyStorKill * 1024);
#ifdef HPCGAP
AddGCRoots();
CreateMainRegion();
#else
void * p = ActiveGAPState();
GC_add_roots(p, (char *)p + sizeof(GAPState));
#endif
for (i = 0; i <= MAX_GC_PREFIX_DESC; i++) {
BuildPrefixGCDescriptor(i);
/* This is necessary to initialize some internal structures
* in the garbage collector: */
GC_generic_malloc(sizeof(BagHeader) + i * sizeof(Bag), GCMKind[i]);
}
#endif /* DISABLE_GC */
}
示例2: on_gc_notification
static void
on_gc_notification (GCEventType event)
{
MonoGCEvent e = (MonoGCEvent)event;
switch (e) {
case MONO_GC_EVENT_PRE_STOP_WORLD:
MONO_GC_WORLD_STOP_BEGIN ();
mono_thread_info_suspend_lock ();
break;
case MONO_GC_EVENT_POST_STOP_WORLD:
MONO_GC_WORLD_STOP_END ();
break;
case MONO_GC_EVENT_PRE_START_WORLD:
MONO_GC_WORLD_RESTART_BEGIN (1);
break;
case MONO_GC_EVENT_POST_START_WORLD:
MONO_GC_WORLD_RESTART_END (1);
mono_thread_info_suspend_unlock ();
break;
case MONO_GC_EVENT_START:
MONO_GC_BEGIN (1);
#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters)
mono_perfcounters->gc_collections0++;
#endif
gc_stats.major_gc_count ++;
gc_start_time = mono_100ns_ticks ();
break;
case MONO_GC_EVENT_END:
MONO_GC_END (1);
#if defined(ENABLE_DTRACE) && defined(__sun__)
/* This works around a dtrace -G problem on Solaris.
Limit its actual use to when the probe is enabled. */
if (MONO_GC_END_ENABLED ())
sleep(0);
#endif
#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters) {
guint64 heap_size = GC_get_heap_size ();
guint64 used_size = heap_size - GC_get_free_bytes ();
mono_perfcounters->gc_total_bytes = used_size;
mono_perfcounters->gc_committed_bytes = heap_size;
mono_perfcounters->gc_reserved_bytes = heap_size;
mono_perfcounters->gc_gen0size = heap_size;
}
#endif
gc_stats.major_gc_time_usecs += (mono_100ns_ticks () - gc_start_time) / 10;
mono_trace_message (MONO_TRACE_GC, "gc took %d usecs", (mono_100ns_ticks () - gc_start_time) / 10);
break;
}
mono_profiler_gc_event (e, 0);
}
示例3: ml_print_plot_data
GC_USER_FUNC void
ml_print_plot_data (void)
{
#if defined(GC_CHERI)
unsigned long long
heapsyinit = GC_THREAD_LOCAL_HEAP_SIZE,
heapsycurr = GC_cheri_getlen(GC_state.thread_local_region.tospace),
heapsymaxb = GC_state.thread_local_region.max_grow_size_before_collection,
heapsymaxa = GC_state.thread_local_region.max_grow_size_after_collection;
printf("[plotdata] # heap size: (young generation) I=%llu B=%llu A=%llu F=%llu\n",
heapsyinit, heapsymaxb, heapsymaxa, heapsycurr);
#ifdef GC_GENERATIONAL
unsigned long long
heapsoinit = GC_OLD_GENERATION_SEMISPACE_SIZE,
heapsocurr = GC_cheri_getlen(GC_state.old_generation.tospace),
heapsomaxb = GC_state.old_generation.max_grow_size_before_collection,
heapsomaxa = GC_state.old_generation.max_grow_size_after_collection;
printf("[plotdata] # heap size: (old generation) I=%llu B=%llu A=%llu F=%llu\n",
heapsoinit, heapsomaxb, heapsomaxa, heapsocurr);
#endif // GC_GENERATIONAL
#elif defined(GC_BOEHM)
printf("[plotdata] # Boehm heap size: %llu\n",
(unsigned long long) GC_get_heap_size());
#endif
}
示例4: cleanup_main
/* Cleanup */
void cleanup_main(void *data)
{
ScmVM *vm = Scm_VM();
if (profiling_mode) {
Scm_ProfilerStop();
Scm_EvalCString("(profiler-show)",
SCM_OBJ(Scm_GaucheModule()),
NULL); /* ignore errors */
}
/* EXPERIMENTAL */
if (stats_mode) {
fprintf(stderr, "\n;; Statistics (*: main thread only):\n");
fprintf(stderr,
";; GC: %zubytes heap, %zubytes allocated\n",
GC_get_heap_size(), GC_get_total_bytes());
fprintf(stderr,
";; stack overflow*: %ldtimes, %.2fms total/%.2fms avg\n",
vm->stat.sovCount,
vm->stat.sovTime/1000.0,
(vm->stat.sovCount > 0?
(double)(vm->stat.sovTime/vm->stat.sovCount)/1000.0 :
0.0));
}
/* EXPERIMENTAL */
if (SCM_VM_RUNTIME_FLAG_IS_SET(vm, SCM_COLLECT_LOAD_STATS)) {
Scm_Eval(SCM_LIST2(SCM_INTERN("profiler-show-load-stats"),
SCM_LIST2(SCM_INTERN("quote"),
vm->stat.loadStat)),
SCM_OBJ(Scm_GaucheModule()),
NULL); /* ignore errors */
}
}
示例5: on_gc_notification
static void
on_gc_notification (GCEventType event)
{
MonoGCEvent e = (MonoGCEvent)event;
if (e == MONO_GC_EVENT_PRE_STOP_WORLD)
mono_thread_info_suspend_lock ();
else if (e == MONO_GC_EVENT_POST_START_WORLD)
mono_thread_info_suspend_unlock ();
if (e == MONO_GC_EVENT_START) {
if (mono_perfcounters)
mono_perfcounters->gc_collections0++;
mono_stats.major_gc_count ++;
gc_start_time = mono_100ns_ticks ();
} else if (e == MONO_GC_EVENT_END) {
if (mono_perfcounters) {
guint64 heap_size = GC_get_heap_size ();
guint64 used_size = heap_size - GC_get_free_bytes ();
mono_perfcounters->gc_total_bytes = used_size;
mono_perfcounters->gc_committed_bytes = heap_size;
mono_perfcounters->gc_reserved_bytes = heap_size;
mono_perfcounters->gc_gen0size = heap_size;
}
mono_stats.major_gc_time_usecs += (mono_100ns_ticks () - gc_start_time) / 10;
mono_trace_message (MONO_TRACE_GC, "gc took %d usecs", (mono_100ns_ticks () - gc_start_time) / 10);
}
mono_profiler_gc_event (e, 0);
}
示例6: initGC
jboolean initGC(Options* options) {
GC_set_no_dls(1);
GC_set_java_finalization(1);
GC_INIT();
if (options->maxHeapSize > 0) {
GC_set_max_heap_size(options->maxHeapSize);
}
if (options->initialHeapSize > 0) {
size_t now = GC_get_heap_size();
if (options->initialHeapSize > now) {
GC_expand_hp(options->initialHeapSize - now);
}
}
objectGCKind = GC_new_kind(GC_new_free_list(), GC_MAKE_PROC(GC_new_proc(markObject), 0), 0, 1);
largeArrayGCKind = GC_new_kind(GC_new_free_list(), GC_DS_LENGTH, 1, 1);
atomicObjectGCKind = GC_new_kind(GC_new_free_list(), GC_DS_LENGTH, 0, 1);
referentEntryGCKind = gcNewDirectBitmapKind(REFERENT_ENTRY_GC_BITMAP);
if (rvmInitMutex(&referentsLock) != 0) {
return FALSE;
}
if (rvmInitMutex(&gcRootsLock) != 0) {
return FALSE;
}
GC_set_warn_proc(gcWarnProc);
return TRUE;
}
示例7: on_gc_heap_resize
static void
on_gc_heap_resize (size_t new_size)
{
guint64 heap_size = GC_get_heap_size ();
mono_perfcounters->gc_committed_bytes = heap_size;
mono_perfcounters->gc_reserved_bytes = heap_size;
mono_perfcounters->gc_gen0size = heap_size;
mono_profiler_gc_heap_resize (new_size);
}
示例8: java_lang_Runtime_totalMemory__
JAVA_LONG java_lang_Runtime_totalMemory__(JAVA_OBJECT me)
{
//XMLVM_BEGIN_NATIVE[java_lang_Runtime_totalMemory__]
#ifndef XMLVM_NO_GC
return GC_get_heap_size();
#else
return 0L;
#endif
//XMLVM_END_NATIVE
}
示例9: epicMemInfo
void epicMemInfo() {
GC_gcollect();
int heap = GC_get_heap_size();
int free = GC_get_free_bytes();
int total = GC_get_total_bytes();
printf("Heap size %d\n", heap);
printf("Heap used %d\n", heap-free);
printf("Total allocations %d\n", total);
}
示例10: ml_print_gc_stats
GC_USER_FUNC void
ml_print_gc_stats (void)
{
#if defined(GC_CHERI)
GC_debug_print_region_stats(&GC_state.thread_local_region);
#ifdef GC_GENERATIONAL
GC_debug_print_region_stats(&GC_state.old_generation);
#endif // GC_GENERATIONAL
#elif defined(GC_BOEHM)
printf("Boehm heap size: %llu\n", (unsigned long long) GC_get_heap_size());
#endif // GC selector
}
示例11: on_gc_heap_resize
static void
on_gc_heap_resize (size_t new_size)
{
guint64 heap_size = GC_get_heap_size ();
#ifndef DISABLE_PERFCOUNTERS
if (mono_perfcounters) {
mono_perfcounters->gc_committed_bytes = heap_size;
mono_perfcounters->gc_reserved_bytes = heap_size;
mono_perfcounters->gc_gen0size = heap_size;
}
#endif
mono_profiler_gc_heap_resize (new_size);
}
示例12: main
int main()
{
int i;
GC_INIT(); /* Optional on Linux/X86; see below. */
for (i = 0; i < 10000000; ++i)
{
int **p = (int **) GC_MALLOC(sizeof(int *));
int *q = (int *) GC_MALLOC_ATOMIC(sizeof(int));
assert(*p == 0);
*p = (int *) GC_REALLOC(q, 2 * sizeof(int));
if (i % 100000 == 0)
printf("Heap size = %d\n", GC_get_heap_size());
}
return 0;
}
示例13: on_gc_notification
static void
on_gc_notification (GCEventType event)
{
if (event == MONO_GC_EVENT_START) {
mono_perfcounters->gc_collections0++;
mono_stats.major_gc_count ++;
gc_start_time = mono_100ns_ticks ();
} else if (event == MONO_GC_EVENT_END) {
guint64 heap_size = GC_get_heap_size ();
guint64 used_size = heap_size - GC_get_free_bytes ();
mono_perfcounters->gc_total_bytes = used_size;
mono_perfcounters->gc_committed_bytes = heap_size;
mono_perfcounters->gc_reserved_bytes = heap_size;
mono_perfcounters->gc_gen0size = heap_size;
mono_stats.major_gc_time_usecs += (mono_100ns_ticks () - gc_start_time) / 10;
mono_trace_message (MONO_TRACE_GC, "gc took %d usecs", (mono_100ns_ticks () - gc_start_time) / 10);
}
mono_profiler_gc_event ((MonoGCEvent) event, 0);
}
示例14: initGC
jboolean initGC(Options* options) {
GC_INIT();
GC_set_java_finalization(1);
if (options->maxHeapSize > 0) {
GC_set_max_heap_size(options->maxHeapSize);
}
if (options->initialHeapSize > 0) {
size_t now = GC_get_heap_size();
if (options->initialHeapSize > now) {
GC_expand_hp(options->initialHeapSize - now);
}
}
object_gc_kind = GC_new_kind(GC_new_free_list(), GC_MAKE_PROC(GC_new_proc(markObject), 0), 0, 1);
if (rvmInitMutex(&referentsLock) != 0) {
return FALSE;
}
return TRUE;
}
示例15: sysGetHeapSize
int64_t sysGetHeapSize() {
return GC_get_heap_size();
}