m_realloc: Account only allocation size difference in total_bytes_allocated.
diff --git a/py/malloc.c b/py/malloc.c
index c65d38a..a94edd3 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -41,7 +41,12 @@
         printf("could not allocate memory, reallocating %d bytes\n", new_num_bytes);
         return NULL;
     }
-    total_bytes_allocated += new_num_bytes;
+    // At first thought, "Total bytes allocated" should only grow,
+    // after all, it's *total*. But consider for example 2K block
+    // shrunk to 1K and then grown to 2K again. It's still 2K
+    // allocated total. If we process only positive increments,
+    // we'll count 3K.
+    total_bytes_allocated += new_num_bytes - old_num_bytes;
     return ptr;
 }