Getting plugin RAM?


In my plugin, I want to display the RAM usage of my plugin.
Is there a way to do that?
I mean, I only want to display the RAM, which my plugin uses. But I don’t want to include the RAM, which the DAW uses.
But both are sharing the same process. So not sure, if I can get only the plugin RAM usage?

I plan to use the plugin both on Win and on Mac.

As far as I know, there’s no way to do that in any generic fashion.(*) If it’s about something like audio samples loaded into memory, you could manually keep track of that yourself up to some degree.

(*) If it was easily possible, some of the DAWs like Reaper, FL Studio and Plogue Bidule would have probably implemented monitoring the plugin RAM usages a long time ago.

There are malloc hook functions on every major OS that can be inserted between every memory allocation call. I don’t advise you at all to use such a feature from within a plugin, but you could write a simple command line tool that loads instances of your processor and counts the bytes allocated/deallocated. This way you could get the base memory overhead of a fresh instance. Store this in your plugin and count further big allocations and deallocations. I assume that you are most likely loading samples or IRs so that the RAM becomes interesting to the user which will likely be located in few places.

Note: The Editor is not taken into account with this approach

Thanks for your answers.
Not what I was hoping for, but good to know.
And yes, I am indeed loading samples and that’s why I want to monitor the RAM consumption.