diff --git a/xmlmemory.c b/xmlmemory.c
index a3dc737..3572f61 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -554,7 +554,10 @@ xmlMemoryStrdup(const char *str) {
 
 int
 xmlMemUsed(void) {
-     return(debugMemSize);
+    xmlMutexLock(xmlMemMutex);
+    int res = debugMemSize;
+    xmlMutexUnlock(xmlMemMutex);
+    return(res);
 }
 
 /**
@@ -567,7 +570,10 @@ xmlMemUsed(void) {
 
 int
 xmlMemBlocks(void) {
-     return(debugMemBlocks);
+    xmlMutexLock(xmlMemMutex);
+    int res = debugMemBlocks;
+    xmlMutexUnlock(xmlMemMutex);
+    return(res);
 }
 
 #ifdef MEM_LIST
