Right, as I noted, you already get total_topic_count “for free” with $forum_template.
“Try commenting out this line in /bp-forums.php and see if the memory problems persist.”
Sorry to be unclear – yes, exactly – that’s how I found the problem.
I did backtrack through the code, and I think you are right – it is a problem with the BB_Query instance. I would strongly advise against using bp_get_forum_topic_count unless this is addressed!!
Reported on trac: https://trac.buddypress.org/ticket/2421