Reputation: 509
I want to log the memory usage of some web/worker roles which are hosted in windows azure instances.
Is there a way to programmatically check for the currently used memory so I can save this value somewhere for later use?
The only information I found was to get the current thread and then call a method which should return memory usage of the heap. But I don’t think this helps me much at my problem especially when there are some asynchronous calls.
Upvotes: 4
Views: 1165
Reputation: 3325
I am using c# and this seems to be working for me. (Simplified): MS reference link: link
try
{
long bytes = GC.GetTotalMemory(false);
return "RAM used: " + (bytes/1024/1024).ToString() + " MB";
}
catch (Exception ex)
{
return "No RAM info available!";
}
Upvotes: 0
Reputation: 4375
Azure Diagnostics is a good point to start. You can add any performance counter you like: Memory Consumption, CPU usage, etc.
Those Counters will be saved in Table Storage under the Table Name "WADPerformanceCounters"
This article may also be of help: http://msdn.microsoft.com/en-us/library/windowsazure/dn186185.aspx
Upvotes: 3