Skip to content

Commit

Permalink
Add TOTAL_MEM_USED to interpinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
nwellnhof committed Feb 1, 2011
1 parent 00d27fb commit 017627f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
7 changes: 7 additions & 0 deletions include/parrot/gc_api.h
Expand Up @@ -76,6 +76,7 @@ typedef void (*gc_object_fn_type)(PARROT_INTERP, struct Memory_Pools *, struct F

typedef enum {
TOTAL_MEM_ALLOC = 1,
TOTAL_MEM_USED,
GC_MARK_RUNS,
GC_COLLECT_RUNS,
ACTIVE_PMCS,
Expand Down Expand Up @@ -347,6 +348,10 @@ PARROT_EXPORT
size_t Parrot_gc_total_memory_allocated(PARROT_INTERP)
__attribute__nonnull__(1);

PARROT_EXPORT
size_t Parrot_gc_total_memory_used(PARROT_INTERP)
__attribute__nonnull__(1);

PARROT_EXPORT
int Parrot_gc_total_pmcs(PARROT_INTERP)
__attribute__nonnull__(1);
Expand Down Expand Up @@ -490,6 +495,8 @@ void Parrot_unblock_GC_sweep(PARROT_INTERP)
#define ASSERT_ARGS_Parrot_gc_total_memory_allocated \
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_gc_total_memory_used __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_gc_total_pmcs __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_gc_total_sized_buffers __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
Expand Down
16 changes: 15 additions & 1 deletion src/gc/api.c
Expand Up @@ -805,7 +805,13 @@ Return the number of lazy mark runs the GC has performed.
=item C<size_t Parrot_gc_total_memory_allocated(PARROT_INTERP)>
Return the total number of memory allocations made by the GC.
Return the total number of bytes allocated by the GC.
=item C<size_t Parrot_gc_total_memory_used(PARROT_INTERP)>
Return the total number of bytes used. This is lower than the allocated
memory because of fragmentation and freed memory that is not returned
to the OS.
=item C<size_t Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)>
Expand Down Expand Up @@ -855,6 +861,14 @@ Parrot_gc_total_memory_allocated(PARROT_INTERP)
return interp->gc_sys->get_gc_info(interp, TOTAL_MEM_ALLOC);
}

PARROT_EXPORT
size_t
Parrot_gc_total_memory_used(PARROT_INTERP)
{
ASSERT_ARGS(Parrot_gc_total_memory_used)
return interp->gc_sys->get_gc_info(interp, TOTAL_MEM_USED);
}

PARROT_EXPORT
size_t
Parrot_gc_headers_alloc_since_last_collect(PARROT_INTERP)
Expand Down
2 changes: 2 additions & 0 deletions src/gc/gc_ms.c
Expand Up @@ -1800,6 +1800,8 @@ Parrot_gc_get_info(SHIM_INTERP, Interpinfo_enum which, ARGIN(GC_Statistics *stat
switch (which) {
case TOTAL_MEM_ALLOC:
return stats->memory_allocated;
case TOTAL_MEM_USED:
return stats->memory_used;
case GC_MARK_RUNS:
return stats->gc_mark_runs;
case GC_COLLECT_RUNS:
Expand Down
3 changes: 3 additions & 0 deletions src/interp/inter_misc.c
Expand Up @@ -250,6 +250,9 @@ interpinfo(PARROT_INTERP, INTVAL what)
case TOTAL_MEM_ALLOC:
ret = Parrot_gc_total_memory_allocated(interp);
break;
case TOTAL_MEM_USED:
ret = Parrot_gc_total_memory_used(interp);
break;
case GC_MARK_RUNS:
ret = Parrot_gc_count_mark_runs(interp);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/ops/core.ops
Expand Up @@ -961,8 +961,8 @@ prefix):

=item B<interpinfo>(out INT, in INT)

TOTAL_MEM_ALLOC, GC_MARK_RUNS, GC_COLLECT_RUNS, ACTIVE_PMCS, ACTIVE_BUFFERS,
TOTAL_PMCS, TOTAL_BUFFERS, HEADER_ALLOCS_SINCE_COLLECT,
TOTAL_MEM_ALLOC, TOTAL_MEM_USED, GC_MARK_RUNS, GC_COLLECT_RUNS, ACTIVE_PMCS,
ACTIVE_BUFFERS, TOTAL_PMCS, TOTAL_BUFFERS, HEADER_ALLOCS_SINCE_COLLECT,
MEM_ALLOCS_SINCE_COLLECT, TOTAL_COPIED, IMPATIENT_PMCS, GC_LAZY_MARK_RUNS,
EXTENDED_PMCS, CURRENT_RUNCORE

Expand Down

0 comments on commit 017627f

Please sign in to comment.