implementing memsize tracing