This adds a mode argument to getmemoryinfo. By default the output
will remain the same. However if a mode argument of mallocinfo is
provided the result of glibc malloc_info (if available) will
be returned as a string, as-is.
This is useful for tracking heap usage over time or troubleshooting
memory fragmentation issues.
This is a backport of Core PR10038