core: fix mem statistics when DBG_QM_MALLOC is on
(cherry picked from commit ffb0cb6d2c3a224ce37b575a7f956cfa881bf63b)