Ejemplo n.º 1
0
void
monitor_orcAction (
    v_public entity,
    c_voidp args
    )
{
#ifdef OBJECT_WALK
    c_base base;
    c_object or;
    monitor_orc trace = monitor_orc(args);
    time_t t;
    int count = 0;
    os_address totalSize;

    time (&t);
    base = c_getBase(entity);
    printf ("\r\n################# Start tracing ################## %s\r\n", ctime(&t));
    printf ("Limit             : %d\r\n", trace->extendCountLimit);
    if (trace->filterExpression) {
        printf ("Filter expression : %s\r\n", trace->filterExpression);
    }
    printf ("\r\n");
    fflush(stdout);

    for (or = base->firstObject; or != base->lastObject; ) {
        or = c_header(or)->nextObject;
        monitor_object (or, trace);
        count++;
    };
    ut_walk (u_collection(trace->refTree), display_orc, trace);
    printf ("\r\n");
    printf ("        %d  for %d object headers (%d) and MM headers (%d)\r\n",
        trace->totalObjectCount * (C_SIZEOF(c_header)  + MM_HEADER_SIZE),
        trace->totalObjectCount,
        C_SIZEOF(c_header), MM_HEADER_SIZE);
    totalSize = trace->totalSizeCount + trace->totalObjectCount * (C_SIZEOF(c_header)  + MM_HEADER_SIZE);
    printf ("Total : %d  (%.2f KB)\r\n", totalSize, (double)totalSize/1024.0);
    fflush(stdout);

    trace->totalSizeCount = 0;
    trace->totalObjectCount = 0;
#else
    OS_UNUSED_ARG(entity);
    OS_UNUSED_ARG(args);
#endif
}
Ejemplo n.º 2
0
static void
monitor_object (
    c_object o,
    monitor_orc trace
)
{
    refLeaf ord;
    c_type tr = c_header(o)->type;

    if (tr == NULL) {
        tr = nullType;
    }
    ord = (refLeaf)ut_get (trace->refTree, tr);
    if (ord) {
        ord->rc++;
    } else {
        ord = malloc (C_SIZEOF(refLeaf));
        ord->tr = tr;
        ord->rc = 1;
        ord->prc = 0;
        ut_tableInsert(ut_table(trace->refTree), tr, ord);
    }
}