You can get a complete memory status at any moment in your code by calling xmemory_status(). This function will summarize memory usage on stderr, giving the total allocated amount of memory of each kind (system memory and VM files), the number of opened VM files, and a list of all currently allocated memory blocks. This function is useful for debugging purposes. If you want to make sure you do not have memory leaks, it is recommended to call it as the last command in your program.
If the debug level is set to any value greater than 2, xmemory_status() will also print out diagnostics informations.